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









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  hai... GoodEvening I have one doubt on jsp.please wil u clarify it. how to move one jsp form to another jsp form with out using forward... page. 1)form1.jsp: <html> <form method="post" action="form2.jsp">
Advertisements
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
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
disable the form - JSP-Servlet
Ajax. after response is coming to the jsp page,particular form button... Multiple form are created in Jsp. Servlet is used to insert the data. Ajax is used... wrote jsp page in that 8 forms are there.all forms are same but the input values
login form - JSP-Servlet
login form  Q no.1:- Creat a login form in servlets?  Hi Friend, Try the following code: import java.io.*; import javax.servlet....(""); } } For more information,visit the following link: http://www.roseindia.net/jsp
html form - JSP-Servlet
html form  how to retrieve database value in dropdown list box placed in html form  Hi friend, Visit for more information. http://www.roseindia.net/jsp/ Thanks
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
creation of a form - JSP-Servlet
creation of a form  how to create a question paper using JSP code  Hi Friend, We have taken radiobuttons in our application, you can... visit the following link: http://www.roseindia.net/jsp/online-quiz
multipart/form-data - JSP-Servlet
multipart/form-data  When we are uploading a file we are using the encoded type of form of type multipart/form-data. When we are using... with the example available in http://www.roseindia.net/jsp/file_upload/Sinle
automatic updation of a form - JSP-Servlet
automatic updation of a form   Sir, I need the code for if we fill the details in one page(form) that details should be updated automatically in another table like page.Please provide the code for this problem in JSP or java
JSP:HTML Form in-place Editing - JSP-Servlet
JSP:HTML Form in-place Editing  I have an HTML form (form #1) which...). Now my purpose is to re-populate the same customer form (form #1) based... customer(s)'s data, they will double click which will trigger another (form #2
How to validate a form - JSP-Servlet
How to validate a form   Dear Sir, I have a one jsp ,in that i have a 2 forms ///One form1 as follows Id Subject Status... submit a form without any Id values in a text field i have to get an aleert message
JSP:HTML Form in-place Editing - JSP-Servlet
JSP:HTML Form in-place Editing  Hi, I want to thank the people... developer's needs. This is a follow up to the HTML Form in-place editing. The code... an excellent way of editing a form. I just have a few adjustments if any of you could
creating a feedback form - JSP-Servlet
and submitting the form. so questions are coming from the jsp page and also... i am refining this problem as follows: i am creating a feedback form of a college. this feedback form will ask some question. now depending upon those
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...; <html> <head><title>Using Get Method in JSP Form.<
login form validation - JSP-Servlet
login form validation  hi, how to validate the login form that contains user name and password using post method . the validation should not allow user to login in the address bar thanks regards, anand
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
passing values form javascript - JSP-Interview Questions
passing values form javascript  please i want to pass values from javascript function to jsp code how can i do
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
Login form using Jsp in hibernate - Hibernate
Login form using Jsp in hibernate   Hai Friend, As I new To hibernate, I'm facing problem in My project(JSP with hibernate).. My login form... and entering into Menu Form.. plz can any one help for my problem... Thanks
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
JSP Ajax Form
Ajax Form Example This example explains you how to develop a form that populates dynamically from the database though Ajax call. When user selects employee id from the combo box then the corresponding employee details are populated
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... <html> <head><title>Creating Form in JSP.</title><
jsp or sevlet and html form to send picture to database - JSP-Servlet
jsp or sevlet and html form to send picture to database  Hello guys... that contains his picture to database. What I need are html page for the form that will browse for the picture, jsp or servlet that the info from html will go
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
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
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
multiple form with multiple function in 1 jsp - JSP-Servlet
multiple form with multiple function in 1 jsp  Hi, I'm using Netbean... in triggering my jsp with 2 forms as 1 for registration and 1 for log in. I need to trigger each form to call several function when user click buttons of these forms
how to point my jsp form action to servlet? - JSP-Servlet
how to point my jsp form action to servlet?  I am currently using... was trying to point my jsp action to my servlet.(f.action="../fyp.servletLogin";) fyp is the folder that stores my servlet. Here is my function code in jsp, when user
passing the form values with image upload - JSP-Servlet
passing the form values with image upload  Hii . I want to get the solution for passing values with an image uploading form. I cant access... a solution Regards Sreejith  Hi, I think on the form you can create
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
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 get a values from a multipart/form-data - JSP-Servlet
how to get a values from a multipart/form-data  Dear sir , I... submitForm(f){ var form = document.createElement("form"); with(form) { method = "post"; action = "newEntryDetails2.jsp"; name = "form"; id = "form
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
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 of jsp is to assign as much processing as possible to java Bean component
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
send multiple textbox vaues in to an jsp form to store them in a DB table
send multiple textbox vaues in to an jsp form to store them in a DB table  Hi sir... I am not getting how can i send the multiple input text box values in to an jsp file with additional values to store those values

Ads