Session is not getting Transferred in servlets.
Dear Sir/madam,
I am developing my school project where I have to maintain a login form(invokes Login servlet) which contains the lastname of the user. I am setting this using
HttpSession session = request.getSession(true);
if(session.isNew() == false)
{
session.invalidate();
session = request.getSession(true);
}
System.out.println("Session in first servlet second time
is:"+session.toString());
session.setAttribute("lastname",sel2);
then after submitting this info user will have a "HTML LINK" to go into a DIFFERENT "html file" which invokes Servlet with name "LOGGED" after clicking on submit
I got the session attribute in LOGGED servlet as such here
HttpSession session = request.getSession();
String lastname = (String)session.getAttribute("lastname");
System.out.println(lastname);
when I print this I m getting null into it. I m unable to understand whats wrong with this. I have done the same thing day before yesterday and it worked but it surprisingly giving me "NULL" when I m testing this today morning. Could anyone please throw light on this.I would be very grateful.
Thank You
Sai Krishna
|