jsp form

jsp form

hi sir, one got one got in jsp form after entering the data into the form the data is not saving in the database i will send you code of two forms if dnt understand my problem

View Answers

January 13, 2011 at 1:41 PM

Hi Friend,

Try this:

1)form1.jsp:

<%@page import="java.sql.*"%>
<html>
<form method="post" action="form2.jsp">
<table>
<tr><td>Name:</td><td><input type="text" name="name"></td></tr>
<tr><td>Address:</td><td><input type="text" name="address"></td></tr>
<tr><td></td><td><input type="submit" value="Submit"></td></tr>
</table>
</form>
</html>

2)form2.jsp:

<html>
<form method="post" action="insertdata.jsp">
<table>
<tr><td>Enter Contact No:</td><td><input type="text" name="contact"></td></tr>
<tr><td>Enter Email:</td><td><input type="text" name="email"></td></tr>
<tr><td></td><td><input type="submit" value="submit"></td></tr>
</table>
<input type="hidden" name="name" value="<%=request.getParameter("name")%>">
<input type="hidden" name="address" value="<%=request.getParameter("address")%>">
</form>
</html>

3)insertdata.jsp:

<%@page import="java.sql.*"%>
<%
String name=request.getParameter("name");
String address=request.getParameter("address");
int contact=Integer.parseInt(request.getParameter("contact"));
String email=request.getParameter("address");

try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root"); 
           Statement st=con.createStatement();
           int i=st.executeUpdate("insert into employee(name, address,contactNo,email) values('"+name+"','"+address+"','"+contact+"','"+email+"')");
         con.close();
         out.println("Data is successfully inserted into the database.");
}
catch(Exception e){
    System.out.println(e);

}
         %>

Thanks

Ads









Related Tutorials/Questions & Answers:
jsp form
jsp form  hi sir, one got one got in jsp form after entering the data into the form the data is not saving in the database i will send you code of two forms if dnt understand my problem
jsp form
jsp form  hi i have one excuted jsp form.and in that the data should be dispaly on another jsp form.please help me thanks in advance   Hi Friend, Try this: 1)form1.jsp: <html> <form method="post" action
Advertisements
Search page form in jsp
Search page form in jsp  search form in jsp   Please go through the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/servlets/search.shtml
Example of handling form in JSP
the form in JSP. Can you tell me the the example of handling form in JSP. How to handle a form in JSP? Thanks   Hi, In JSP page you can get the values... at How to handle a form in JSP? Thanks   Hi, In JSP page you can get
search form in jsp
search form in jsp  search page in jsp   Please go through the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/servlets/search.shtml
JSP code for registration form
JSP code for registration form  Haiiii can u please tell me how to encrypt password field in registration form and to compare both password and confirm password fields using jsp
convert this html form to jsp
convert this html form to jsp  <html> <head> <script...;/tr> <form name="VillageDetailsForm" action="AddVillage.jsp" method... Village Registration --> </body></html>   JSP page
Get Method of the Form In JSP
Get Method of the Form In JSP     ... of the form in JSP. The HTTP get method sends data to the server. In your JSP...; <head><title>Using Get Method in JSP Form.</title></head>
Post Method of the Form In JSP
Post Method of the Form In JSP   ... of the post method of the form in JSP. The HTTP post method sends data.... In this section, you will see that the following JSP program creates a form
image upload with jsp from form
image upload with jsp from form  hi i used the code specified in your following post http://www.roseindia.net/answers/viewqa/JSP-Servlet/9749-image...) org.apache.jsp.upload_jsp._jspService(upload_jsp.java:85
Get form value in same page - JSP-Servlet
Get form value in same page  Hello friends, Can we get a form field value in the same to be processed in java coding... friend, For solving the problem visit to : http://roseindia.net/jsp/user
How to handle a form in JSP
How to handle a form in JSP   ... and the procedure of handling the form through the JSP code. This section provides JSP code which used the HTML code for creating a form and this form is handled
how to use one form out of multiple form from one jsp to another jsp
how to use one form out of multiple form from one jsp to another jsp  ... a .jsp( say abc.jsp) file which contains multiple Action form.I am required to add one form from abc.jsp as it is to another .jsp(say def.jsp).Your advise
Exception during parsing a parameter from the form in JSP
Exception during parsing a parameter from the form in JSP  Exception during parsing params from a form? I get parameters from a html form. I parse the integer one in the JSP file, but I get exception. Is there anyway I can get
How to create a form in JSP
How to create a form in JSP   ... of the creation of a form through the HTML code in the JSP page. You can simply use...;title>Creating Form in JSP.</title></head> <body> <
How to validate a form in action class and forward errors to the jsp in struts?
How to validate a form in action class and forward errors to the jsp in struts?  How to validate a form in action class and forward errors to the jsp in struts
Problem in enctype="multipart/form-data" in JSP
Problem in enctype="multipart/form-data" in JSP  im using a page which is in JSP. i have some text boxes and one upload button. i want to load the file itself when i click the submit button. im using enctype="multipart/form-data
JSP to add details to a database from a HTML form.
JSP to add details to a database from a HTML form.  Hi I'm a second year CS student who has to use JSP to validate a HTML form and add the details... , then the jsp validation side after below.. <html> <body> <center>
how to write a jsp form using html
how to write a jsp form using html  hi, i have written the code...; <body> <form method="POST" action="Form1.jsp"> EmployeeNo: <...; </form> <p></body> </html> .jsp file <
what is wrong with my JSP codes for updating a form?
what is wrong with my JSP codes for updating a form?  Hi experts...;form action="Update.jsp" method ="post" name="update"> <...; <h5>Member Update Form </h5> <input type = "hidden
how to display action errors in jsp which is in a form list
how to display action errors in jsp which is in a form list  My jsp contains list of forms iterating using display:table, each FORM forms a row. I want to display action errors for individual form in the same row
add cookies to login form in jsp by using struts2.0 framework
add cookies to login form in jsp by using struts2.0 framework  hi sir... struts2.0 and hibernate3.0 and mysql database for login .jsp now i want to add cookies to above form please help me
HTML(Registration form) to Jsp to stored into MS ACCESS database
HTML(Registration form) to Jsp to stored into MS ACCESS database  i am sending one html file that contain 18 fields these are stored in ms-access database by using jsp code.i want to urgent jsp code. please urgent sir. thank
linking tree heading in javasript into a Jsp file and then jsp to struts action form
linking tree heading in javasript into a Jsp file and then jsp to struts action form  i have a tree that consists of 3 options say for example 1... to the corresponding jsp say 1) aaa_jsp.jsp 2) bbb_jsp.jsp 3) ccc_jsp.jsp how
database connectivity in jsp form
database connectivity in jsp form We are going to create jsp registration form database. We first create simple registration form. All data ... in this form. We can insert, update, delete any data in this form
How to save form fields into the MySql Database without submit button in jsp?
How to save form fields into the MySql Database without submit button in jsp?  I want to store user inputs into the database using javasccript or ajax or jqury but without submit button. Form Contains three fields
How to retrieve array values from html form to jsp?
How to retrieve array values from html form to jsp?  Hi! I am... it into jsp. Means i just want to retrieve values from html form containing array to jsp page and store them in the session variable. So plz any1 can send me
User Registration Form Using JSP(JspBeans)
User Registration Form Using JSP(JspBeans)  ... of user registration form using jsp. One of the basic programming tactics...;html> <body > <form action="/examples/jsp/proces.jsp
userregistration code -- http://www.roseindia.net/jsp/user-registration-form-using-jsp.shtml
userregistration code -- http://www.roseindia.net/jsp/user-registration-form-using-jsp.shtml  While running this application on netbeans7.0 , i am getting the following error: message /userregister/ description The requested
Need to develop a control panel for application form which is developed in jsp
Need to develop a control panel for application form which is developed in jsp  I have created one application page which contains some check boxes,radio buttons and text boxes in jsp this for user to fill it. Now I need
User Registration Form Using JSP(JspBeans) after that how i can insert in database
User Registration Form Using JSP(JspBeans) after that how i can insert in database   User Registration Form Using JSP(JspBeans) after that how i can insert in database

Ads