Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


tejasri
jsp form
1 Answer(s)      3 years and 10 months ago
Posted in : JSP-Servlet


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


Advertisement
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...)form1.jsp: <html> <form method="post" action="form2.jsp"> <table>
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
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
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
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
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
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
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
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
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
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
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>
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
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
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
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
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
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
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> <
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 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 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>
 

 

 

DMCA.com