I am a Computer Science student and have done some projects in java and also familiar with CGI/Perl. I am also learning JSPservlets. Now I am working in a project where I have to keep track of the logged person in a series of pages. As I knew CGI/perl session concept I am using the JSP sessions to do this. I am able to set sessions in one JSP page and retrive them in other. But in the CGI/perl scripts I used to set a session. The next page will get this session ID either from cookie or from query string and then gets the required variable from the session file. I wonder how the JSP file gets the session file to verify without the session ID. Please anyone help me to solve my this basic doubt.
Joined: Oct 12, 2000
The JSP will get the session for you automatically. Unlike in Perl you don't have to specifically get it from the request. The JSP is compiled into a Java servlet the first time it is run, and the code to get the session from the request is generated for you at that time so you can just access the session as if it always existed. That same code will also generate a new session for you if none exists, so that too you don't have to worry about.
Joined: May 19, 2004
It is because of implicit object "session" which is present automatically in jsp.
Joined: May 25, 2004
I think now I understand JSP sessions better.. Thanks a lot