Hello i am developing a web Application.. Where on login the user will be redirected to his respected login page with a welcome text as WElCOME Username.. But when the user navigates to some other page and comes back it is displaying welcome msg as null... How to keep the username constant on the homepage even after navigation to different pages??
I use this code on JSp to display Welcome msg:
String un = request.getParameter("txtUsername");
out.println("Welcome " + un);
An d my LoginServlet is this:
String username = request.getParameter("txtUsername");
String category = (request.getParameter("txtCategory"));
Login login = new Login();
login.setUserName(username);
login.setPassWord(request.getParameter("txtPassword"));
login.setCategory(category);
LoginService ls = new LoginService();
ls.loginValidate(login);
Boolean check = ls.loginValidate(login);
if (check == true) {
HttpSession session = request.getSession();
// setting attribute on session
session.setAttribute("user", username);
if (category != null) {
if (category.equalsIgnoreCase("Admin")) {
RequestDispatcher rd = request
.getRequestDispatcher("WEB-INF/WebPages/Admin.jsp");
rd.forward(request, response);
} else if (category.equalsIgnoreCase("Affiliate")) {
RequestDispatcher rd = request
.getRequestDispatcher("WEB-INF/WebPages/Affiliate.jsp");
rd.forward(request, response);
} else {
RequestDispatcher rd = request
.getRequestDispatcher("WEB-INF/WebPages/Client.jsp");
rd.forward(request, response);
}
}
}
else {
RequestDispatcher rd = request
.getRequestDispatcher("WEB-INF/WebPages/Error.jsp");
rd.forward(request, response);
}
}
Please help me fix this.. Thanks in advance....