0

ViewServlet.java:

            List<User> list=EmpDao.getAllEmployees();  

            out.print("<table border='1' width='100%'");  
            out.print("<tr><th>ID</th><th>USERNAME</th><th>PASSWORD</th><th>FIRSTNAME</th><th>LASTNAME</th><th>CITY</th><th>ADDRESS</th><th>COUNTRY</th>");  

              out.print("</table>");    
            out.close(); 
  • My objective is to write html code in 'ViewServlet.java' into pure html code in 'result.jsp'.
  • What i am expecting is if i write pure html code in jsp then all the records will be retrieved from "MYSQL" will be displayed in ViewServlet.java.If i want to edit,delete then will happen in 'ViewServlet.java'
  • I tried request.getAttribute for ID, USERNAME, PASSWORD, FIRSTNAME, LASTNAME, CITY, ADDRESS, COUNTRY[parameters]. Well my brother guided me to write following -

request.getRequestDispatcher(request.getContextPath()+"/result.jsp") .forward(request, response);

I am new to JSP,SERVlETS please provide a solution.Thank you.

result.jsp

 <%{
        ArrayList list = (ArrayList)request.getAttribute("alist");
        for(int i = 0; i<list.size(); i++) { 
            User user = (User)list.get(i); %>
        <tr>     
        <td><%=user.getID()%></td>
        <td><%=user.getUSERNAME()%></td>
        <td><%=user.getPASSWORD()%></td>
        <td><%=user.getFIRSTNAME()%></td>
        <td><%=user.getLASTNAME()%></td>
        <td><%=user.getCITY()%></td>
        <td><%=user.getADDRESS()%></td>
        <td><%=user.getCOUNTRY()%></td>
        </tr>
        <%
        ArrayList<User> list = (ArrayList<User>)request.getAttribute("/ViewServlet.java");
        for(User e:list){
            out.println(e.getID());
            out.println(e.getUSERNAME());
            out.println(e.getPASSWORD());
            out.println(e.getFIRSTNAME());
            out.println(e.getLASTNAME());
            out.println(e.getCITY());
            out.println(e.getADDRESS());
            out.println(e.getCOUNTRY());

        }%>
  • Here after 8 parameters add two hyperlinks such has EDIT,DELETE ,My objective here is to add two hyperlinks Edit,delete servlets(EDITSERVLET,DELETESERVLET) so that i can edit,delete records in the table.

  • Here i am getting error has "UNABLE TO COMPILE CLASS OF JSP".

  • I dont know why i am getting error at "line 33" i mentioned it above.

    Kindly help me.Thank you..

Chirag Parmar
  • 833
  • 11
  • 26
Koushik Reddy
  • 31
  • 1
  • 6

1 Answers1

1
request.getRequestDispatcher(request.getContextPath()+"/youjsppage.jsp")
                                      .forward(request, response);
Bills
  • 768
  • 7
  • 19