My servlet doesnt get session value "user" its always null
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
HttpSession session = request.getSession(true);
String user = (String)session.getAttribute("user");
System.out.println("Session check"+user);
//For some reason the user is always null..... In the previous jsp page when I say String user = (String)session.getAttribute("user"); if(user == null) { response.sendRedirect("index.jsp"); -- This works and it gets the user...
if(user == null) {
RequestDispatcher rd = null;
rd = getServletConfig().getServletContext().getRequestDispatcher("/index.jsp");
if (rd!=null)
rd.forward(request,response);
}
I havent changed the value of user at all... In previous JSP it accepts the user in session and gets the value.... in the servlet its not.. any ideas? The jsp page uses POST method and this servlet is called using that.