Hi, Below is the front page of my project
1)enty.jsp
</form> </body> </html> </form> </body> </html>> <html> <body> > > <form method="post" action="get"> > <b><div > style="text-align:center"><font > size="6"><font > color="red"></font><font > color="blue">B-E FORM:</font></div> > <b><font color="marron" > size="4">ENTER PIS NO.:</font> > <input type= "text" name="pis"><br><br> <input > type="submit" value="Submit"> > > </form> </body> </html></form> </body> </html> </form> </body> </html> Now as the user click submit button he will reach to updation.java servlet through WEB.XML 2)**WEB.XML** <web-app> <servlet> <servlet-name>updation</servlet-name> <servlet-class>updation</servlet-class> </servlet> <servlet-mapping> <servlet-name>updation</servlet-name> <url-pattern>/updation</url-pattern> </servlet-mapping> </web-app> 3)**updation.java** import java.sql.*; import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; public class updation extends HttpServlet { protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { int pisNo =Integer.parseInt( req.getParameter("pis") ); List list=new ArrayList(); try { Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/drona","root","daemons"); Statement st = con.createStatement(); ResultSet rs = st.executeQuery("select * from dronadb2 where pisNo=" + pis ); do{ list.add(rs.getString("b1")); list.add(rs.getString("b2")); list.add(rs.getString("pyr1")); list.add(rs.getString("univ1")); list.add(rs.getString("subject1")); list.add(rs.getString("gradeyr1")); list.add(rs.getString("pyr2")); list.add(rs.getString("univ2")); list.add(rs.getString("subject2")); list.add(rs.getString("gradeyr2")); list.add(rs.getString("pyr3")); list.add(rs.getString("univ3")); list.add(rs.getString("subject3")); list.add(rs.getString("gradeyr3")); list.add(rs.getString("qual1")); list.add(rs.getString("pyr4")); list.add(rs.getString("univ4")); list.add(rs.getString("subject4")); list.add(rs.getString("gradeyr4")); list.add(rs.getString("qual2")); list.add(rs.getString("pyr5")); list.add(rs.getString("univ5")); list.add(rs.getString("subject5")); list.add(rs.getString("gradeyr5")); list.add(rs.getString("title")); list.add(rs.getString("day6")); list.add(rs.getString("month6")); list.add(rs.getString("yr6")); list.add(rs.getString("gradeyr3")); list.add(rs.getString("day7")); list.add(rs.getString("month7")); list.add(rs.getString("yr7")); list.add(rs.getString("inst")); }while(rs.next()); req.setAttribute("data", list); RequestDispatcher rqd = req.getRequestDispatcher("b-e(1).jsp"); rqd.forward(req, res); rs.close(); st.close(); con.close(); } catch (Exception e) { } } } Now the servlet should pass the value retrieve from the database to the text boxes of b-e(1).jsp , 4)**b-e(1).jsp** Hre radio buttons are also used and i dont know whether i used the correct method to display the data from database via servlet to radio buttons f jsp is correct or not <%@page language="java" import="java.util.*" %> <html> <body> <form method="post" action="servlet"> <% Iterator itr; List data=(List)request.getAttribute("data"); for(itr=data.iterator(); itr.hasNext(); ){ %> <table> <tr> <fieldset> <div style="text-align:center"> <font size="3"> <font color="red">* </font> <font color="blue"> EDUCATION QUALIFICATION </font> </font> </div> </fieldset> <br> </tr> <tr> <td><font color="blue">Degree</td> <td><font color="blue">Passing Year</td> <td><font color="blue">Â Â Â Â University/Institute</td> <td><font color="blue">Â Â Â Â Â Subject</td> <td><font color="blue">Div/Class/Grade</td></font> </tr> <tr> <td> <font color="red">*</font><font size="3"><b>Graduation</font><br> <fieldset> <font color="red"><input type="radio" name="rd1" value="<%=itr.next()%>" /> Engg. <input type="radio" name="rd2" value="<%=itr.next()%>" /> Non-Engg.</font> </fieldset> </td> <td> <input type="text" cols="5" value="<%=itr.next()%>" name="year1"> </td> <td> <input type="text" cols="5" value="<%=itr.next()%>" name="inst1"> </td> <td> <input type="text" value="<%=itr.next()%>" name="sub1"> </td> <td> <input type="text" value="<%=itr.next()%>" name="year1.1"> </td> </tr> <tr> <td> Post Graduation </td> <td> <input type="text" value="<%=itr.next()%>" name="year2"> </td> <td> <input type="text" value="<%=itr.next()%>" name="inst2"> </td> <td> <input type="text" value="<%=itr.next()%>" name="sub2"> </td> <td> <input type="text" value="<%=itr.next()%>" name="year2.2"> </td> </tr> <tr> <td> <font color="red">(Compulsary for Science Graduates)</font> </td> </tr> <tr> <td> Ph D/Post doctrate </td> <td> <input type="text" value="<%=itr.next()%>" name="year3"> </td> <td> <input type="text" value="<%=itr.next()%>" name="inst3"> </td> <td> <input type="text" value="<%=itr.next()%>" name="sub3"> </td> <td> <input type="text" value="<%=itr.next()%>" name="year3.1"> </td> </tr> <tr> <td> <input type="text" value="<%=itr.next()%>" name="qualfi1"> </td> <td> <input type="text" value="<%=itr.next()%>" name="year4"> </td> <td> <input type="text" value="<%=itr.next()%>" name="inst4"> </td> <td> <input type="text" value="<%=itr.next()%>" name="sub4"> </td> <td> <input type="text" value="<%=itr.next()%>" name="year4.1"> </td> </tr> <tr> <td> <input type="text" value="<%=itr.next()%>" name="qualfi2"> </td> <td> <input type="text" value="<%=itr.next()%>" name="year5"> </td> <td> <input type="text" value="<%=itr.next()%>" name="inst5"> </td> <td> <input type="text" value="<%=itr.next()%>" name="sub5"> </td> <td> <input type="text" value="<%=itr.next()%>" name="year5.1"> </td> </tr> </table> <br><br> <table> <tr> <fieldset> <b> <div style="text-align:center"> <font size="3"> <font color="red">* </font> <font color="DarkGreen"> DETAILS OF SERVICE </font> </font> </b> </div> </fiedset> <br> </tr> <tr> <td><font color="DarkGreen">Grade/Post</td></font> <td><td><td><td><td><font color="DarkGreen">Â Â From</td></font> <td><td><td><td><td><td><font color="DarkGreen">Â Â To</td></font> </tr> <tr> <td> <input type="text" name="grade"> </td> <td> </td> <td> </td> <td> <input type="text" name="day6"> </td> <td> <input type="text" name="month6"> </td> <td> <input type="text" name="year6"> </td> <td> </td> <td> </td> <td> <input type="text" name="day7"> </td> <td> <input type="text" name="month7"> </td> <td> <input type="text" name="year7"> </td> <td> </td> <td> <td> <td> <input type="text" name="lb"> </td> </tr> </table> <br> <table> <tr><tr><tr> <div align="left"> <div style="background-color:lightgray; border: 1px solid black;padding: 7spx; text-align: center;width: 300px;"> <span style="color: blue;">Add New Record Of Service</span> </div></div> </td> </tr> </table><br> <table> <tr><fieldset> <div style="text-align:center"><font size="3"><font color="red">* </font><font color="blue">TRAINING COURSES ATTENDED IN THE PRESENT GRADE (including CEP)</font></div> </tr></fiedset> <br><tr> <input type="checkbox" name="" value=""> <font color="red">NIL</font><br> </tr> <tr> <td>Course Title</td> <td><td><td><td><td>Â Â From</td> <td><td><td><td><td><td>Â Â To</td> <td><td><td><td><td>Â Â Institution</td> </tr> <tr> <td> <input type="text" value="<%=itr.next()%>" name="title"> </td> <td><td><td><td> <input type="text" value="<%=itr.next()%>" name="day8"> </td> <td> <input type="text" value="<%=itr.next()%>" name="month8"> </td> <td> <input type="text" value="<%=itr.next()%>" name="year8"> </td> <td><td><td><td> <input type="text" value="<%=itr.next()%>" name="day9"> </td> <td> <input type="text" value="<%=itr.next()%>" name="month9"> </td> <td> <input type="text" value="<%=itr.next()%>" name="year9"> </td> <td><td><td><td> <input type="text" value="<%=itr.next()%> name="inst"> </td> </tr> </table><br> <table> <tr> <tr><tr> <div align="left"> <div style="background-color:lightgray; border: 1px solid black;padding: 7spx; text-align: center;width: 300px;"> <span style="color: blue;">Add New Training Course</span> </div></div> </td> </tr> <tr> <td><input type="submit" value="SAVE AND PROCEED"></td> </tr> <%}%> </table> </form> </body> </html>
Please go through the following link:
Ads