0

Hi,
I'm having my login page as:

<html><head><body>
<form action="validateuser.jsp" method="POST">
username - <input type="text" name="userName">
password - <input type="password" name="passWord">
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form></body></html>

And Validator Page as :

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import="java.util.*" %>
<jsp:useBean id="idHandler" class="com.suntec.tbms3.ui.Login" scope="request">
<jsp:setProperty name="idHandler" property="*"/>
</jsp:useBean>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head><body>
<%
String userName = request.getParameter("userName");
String passWord = request.getParameter("passWord");
if (idHandler.authenticate(userName, passWord))
{
response.sendRedirect("welcome.jsp");
} 
else 
{
response.sendRedirect("retry.jsp");
}
%>
</body></head>
</html>

where I'm validating the username and pass word from my DB.
Now I want to display the user login name in my welcom.jsp page. what are the modification i've to do in validator.jsp and welcome.jsp

3
Contributors
5
Replies
21
Views
8 Years
Discussion Span
Last Post by Ponmari
0

I am new to jsp but I would do either one of the following:

1. Set the username as a session variable and then in welcome.jsp u can use

<%=session.getAttribute("userName")%>

2. Send the username in the querystring when redirecting to the welcome page then just use

request.getParameter("userName")

to display it.

0

can you please little bit eloborative in the second point.
Here is my reedirect code :

response.sendRedirect("welcome.jsp?name="+userName);

then how could I able to display the value in the welcome.jsp

1

If the redirect is to look like this

response.sendRedirect("welcome.jsp?name="+userName);

then to get the username from the query string you would use it just as u did earlier (from your original post "String userName = ......") , like this:

<%=request.getParameter("name")%>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.