want to create a application using jsp pages such that it takes a value from user in a textbox and on the basis of that value it retrives other values from database and fill other textboxes with that retrived values
                
                A: 
                
                
              
            - Create a HTML form and put it in - search.jsp:- <form action="search" method="post"> <input type="text" name="query"> <input type="submit"> </form>
- Create a Java class which - extends HttpServletand does the desired business task:- protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String query = request.getParameter("query"); Data data = someDAOClass.find(query); request.setAttribute("data", data); // Will be available in EL by ${data} request.getRequestDispatcher("search.jsp").forward(request, response); // Return back to JSP page. }- Map this servlet on an - url-patternof- /searchin- web.xmlso that it will be executed then the form in the JSP is submitted.
- Extend the form with the input fields which should display this data. Just fill the - valueattribute of the input elements with the desired information.- <form action="somethingelse" method="post"> <input type="text" name="id" value="${fn:escapeXml(data.id)}" /> <input type="text" name="name" value="${fn:escapeXml(data.name)}" /> <input type="text" name="email" value="${fn:escapeXml(data.email)}" /> <input type="text" name="age" value="${fn:escapeXml(data.age)}" /> ... </form>- The - fn:escapeXmlis by the way there to prevent XSS.
                  BalusC
                   2010-05-06 12:22:10