Mickey
Posts: 7
Nickname: internment
Registered: Feb, 2004
re: JSP page
Posted: Feb 17, 2004 2:32 AM
Advertisement
Hi folks, Below is a html page,bean,servlet and jsp page for the response. My problem is i cannot get the name i enter into the form in the HTML page to appear in the jsp page. The jsp page is being displayed but without the name....what am i doing wrong. Thanks for your help.... THIS IS THE HTML PAGE WITH THE FORM......!!! <html> <head> <title>Register User HTML</title> </head> <body bgcolor="#ffffff"> <table border="0" width="700"> <tr> <td width="150"> </td> <td width="550"> <h1>Register User?</h1> </td> </tr> <tr> <td width="150"> </td> <td width="550"> <form action="http://localhost:8080/servlet/Controller" method="post"> <input type="text" name="name" size="25"> <br> <input type="submit" value="Submit"> <input type="reset" value="Reset"> </td> </tr> </form> </table> </body> </html> THIS IS PART OF THE SERVLET..........!!! protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String userName; userName = request.getParameter("name"); response.setContentType("text/html"); HttpSession session = request.getSession(true); session.setAttribute("userName", userName); if (request.getParameter("name") != null ) { gotoPage("/response.jsp",request,response); } } THIS IS THE BEAN..............!!! public class RegisterHandler { private String username; public RegisterHandler() { username = null; } public void setUsername( String name ) { username = name; } public String getUsername() { return username; } } THIS IS THE JSP RESPONSE PAGE.....!!! <%@ page import="Register.RegisterHandler" %> <jsp:useBean id="registerBean" scope="page" class="Register.RegisterHandler"/> <jsp:setProperty name="registerBean" property="*"/> </jsp:useBean> <table border="0" width="700"> <tr> <td width="150"> </td> <td width="550"> <h1>Names entered is: <jsp:getProperty name="registerBean" property="username" />! </h1> </td> </tr> </table>