Thursday, February 4, 2010

You Must Insert Your Digital Copy To Insert Records Via Jsp Page. Before Inserting It Must Be Checked If The Entered Data Already Exist?

To insert records via jsp page. Before inserting it must be checked if the entered data already exist? - you must insert your digital copy

I would like to insert some records from a table on the JSP page. I want to confirm if you have already entered in the table. It must be made before the presentation (most preferred). After the presentation is okay too.

How can I check. I am using JSP, Servlets, EJB in NetBeans IDE, and JavaScript for validation?

2 comments:

Pramod said...

/ / Pk
Suppose that:
1) = StudentVO.java entity class
2) = EJBHome.java EJB receive support class and save method
-------------------------------------- ...

import javax.servlet.http.HttpServlet;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;


public class HttpServlet TestServlet (
public void service (request, HttpServletResponse response) throws ServletException, IOException (
String id = request.getParameter ( "id"), / / primary key
String name = request.getParameter ( "name");
String address = request.getParameter ( "Address");

try (
Home EJBHome = ........;
StudentVO vo = home.getStudentById (id) / / EJB method to get data from students (object) in the primary key
if (vo! = null) (
/ / Student is already in place
LIA() E.getWriter. out.println ( "This entry is already in the database");
)
else (
StudentVO vo StudentVO new) = (;
vo.setId (id);
vo.setName (name);
vo.setAddress (address);

home.saveStudent VO) (/ / EJB method for backing up student data (object)
)
)
catch (Exception e) (
e.printStackTrace ();
)
)
)

NeoArcan... said...

This is a standard programming - the servlet called DAO (Data Access Object) using the search fields in the database for a duplicate record presented (must be understood in this area, they will be) a "duplicate". If the file is present, an error to the user (with the message on the request / response or session). If the file is not already there, and then make the insertion, and indicate to the user's registry has been successfully registered.

We use this pattern on the screen all incoming data.

And then you learn more about the users who like to learn the button "Send" button / Back / present / previous / file ... and answer the question as to ... Then those who clear / Back / Clear / back to see what happens.

Post a Comment