Click here to Skip to main content
11,644,982 members (65,559 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Java JSP
retrieve value to textbox from database? in jsp


this code is written in servlet:-



protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
       // processRequest(request, response);
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
 
            /* TODO output your page here. You may use following sample code. */
            out.println("<html>");
            out.println("<head>");
            out.println("<title>Servlet recover</title>");
            out.println("</head>");
            out.println("<body>");
 
         ServletContext sc= getServletContext();
         connectivity cc=(connectivity)sc.getAttribute("pankaj");
         String user = request.getParameter("name");
         try {
           String reco="Select * from login where username='"+user+"'";
 
           PreparedStatement ps=cc.getCon().prepareStatement(reco);
           ResultSet rs= ps.executeQuery();
           if(rs.next())
            {
            out.println("username:-");
            out.println(rs.getString(1));
            out.println("<br>password:-");
            out.println(rs.getString(2));
            out.println("<br> <input type=\"text\" value=\"?????\" name=\"name\"/>");
        
           // out.println("<h1>Servlet recover at " + request.getContextPath() + "</h1>");
            out.println("</body>");
            out.println("</html>");
 
            System.out.println("its done ");
            //response.sendRedirect("recover.jsp");
            }
            else
            {
                System.out.println("sorry");
            }
         }
         catch(Exception ex)
         {
             System.out.println("error in recovery"+ex);
         }
    }
 
    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>


plz tell me What to use in out.println("<br> <input type=\"text\" value=\"?????\" name=\"name\"/>");
Posted 30-Dec-12 2:54am
Edited 30-Dec-12 4:47am
TorstenH.34.8K
v3
Comments
WajihAhmed at 30-Dec-12 9:23am
   
You should provide some code,where are you stuck?
pankajbhardwaj at 30-Dec-12 9:41am
   
now plz check out .

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi pankajbhardwaj,

I think the problem is here :
out.println("
 <input type=\"text\" value=\"?????\" name=\"name\"/>");</br>
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 725
1 jyo.net 494
2 Sergey Alexandrovich Kryukov 464
3 Afzaal Ahmad Zeeshan 404
4 CPallini 386
0 OriginalGriff 1,065
1 Sergey Alexandrovich Kryukov 683
2 DamithSL 681
3 Afzaal Ahmad Zeeshan 662
4 CPallini 555


Advertise | Privacy | Mobile
Web02 | 2.8.150731.1 | Last Updated 3 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100