When i am compiling the Formdata it throws the error like 1) Formdata.java overrides or uses a deprecated API 2)Recompile with -Xlint :deprecation for details. I have the following dought also I am writing the fields which are available in Formdata.java in html.Generally we are using the out.println for to see the output.so my dought is 1)is it possible to put the total html code in out.println statement 2)if it is possible send me the code in that view
During compilation, the error indicates that we have used deprecated method. Yes we have used getText(0 method for JPasswordField which is deprecated. Though it does not harm your code and if you want to change this method then use getPassword() method for JPassword fields like password and confirm password and use then as following:
String v4=new String(text4.getPassword()); String v5=new String(text5.getPassword());
out.println is used in jsp not in html.There should be different code for html.
1)form.html:
<html> <form method="post" action="http://localhost:8080/examples/jsp/insert.jsp"> <table> <tr><td>First Name:</td><td><input type="text" name="fname"></td></tr> <tr><td>Last Name:</td><td><input type="text" name="lname"></td></tr> <tr><td>Email:</td><td><input type="text" name="email"></td></tr> <tr><td>Password:</td><td><input type="password" name="pass"></td></tr> <tr><td>Confirm Password:</td><td><input type="password" name="cpass"></td></tr> <tr><td>Date Of Birth</td><td><input type="text" name="dob"></td></tr> <tr><td>Age:</td><td><input type="text" name="age"></td></tr> <tr><td>Gender</td><td><input type="text" name="gender"></td></tr> <tr><td>Address:</td><td><input type="text" name="address"></td></tr> <tr><td>Country</td><td><input type="text" name="country"></td></tr> <tr><td>State:</td><td><input type="text" name="state"></td></tr> <tr><td>City</td><td><input type="text" name="city"></td></tr> <tr><td>Telephone No:</td><td><input type="text" name="tno"></td></tr> <tr><td>Mobile:</td><td><input type="text" name="mobile"></td></tr> <tr><td></td><td><input type="submit" value="Submit"></td></tr> </table> </form> </html>
2)insert.jsp:
<%@page import="java.sql.*,java.util.*"%> <table> <% String fname=request.getParameter("fname"); String lname=request.getParameter("lname"); String email=request.getParameter("email"); String pass=request.getParameter("pass"); String cpass=request.getParameter("cpass"); String dob=request.getParameter("dob"); int age=Integer.parseInt(request.getParameter("age")); String gender=request.getParameter("gender"); String address=request.getParameter("address"); String country=request.getParameter("country"); String state=request.getParameter("state"); String city=request.getParameter("city"); int telephone=Integer.parseInt(request.getParameter("tno")); int mobile=Integer.parseInt(request.getParameter("mobile")); try{ Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/roseindia", "root", "root"); Statement st=con.createStatement(); int i=st.executeUpdate("insert into student(firstname,lastname,email,pass,confirm_pass,dob,age,gender,address,country,state,city,telephone,mobile) values('"+fname+"','"+lname+"','"+email+"','"+pass+"','"+cpass+"','"+dob+"',"+age+",'"+gender+"','"+address+"','"+country+"','"+state+"','"+city+"',"+telephone+","+mobile+")"); out.println("Data is successfully inserted!"); } catch(Exception e){ System.out.print(e); e.printStackTrace(); } %>
Ads