The solution for this is long so by explanation I hope you'll get what you need:
1. Create a JSP page with a form with a method post, inside the form should contain an input field and a button.
<form name="xform" method="post">
<input type="text" name="username">
<input type="button" value="Submit">
</form>
2. Create a Servlet that reads the field username.
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String name = req.getParameter("username
// Here you can call DAO or handle database layer to check if the user is in the database
// After that you pass it below
HttpSession session = request.getSession(true);
session.setAttribute("name
RequestDispatcher rd = request.getRequestDispatch
rd.forward(request, response) ;
}
3. Now in you home.jsp you can call this for the name on the session:
<% String name = (String)session.getAttribu
<% out.println("" + name); %>
That's the simplest way ;)
Main Topics
Browse All Topics





by: suprapto45Posted on 2007-05-23 at 18:46:04ID: 19146299
Hi,
name");
It is pretty easy then.
First, you need to create one JSP with a textbox for user to fill in the user name and a submit button to submit the information. Below is a very very simple version of the login.jsp.
<form name="/report.jsp" method="POST">
<input type="text" name="username" id="username">
<input type="submit" value="Submit">
</form>
Hence, when you press the submit button, it will go to the report.jsp. Then, in the report.jsp, you need to get back the username passed from first jsp file and do the necessary action. In report.jsp, you can get it using request.getParameter("user
Let me know if you have other questions.
David