
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

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
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.