Cafe
Cafe

Reputation: 61

J2ee Session Tracking

In my servlet (after login) I set the session timeout interval as 30 seconds and also note the sessionID as say X

 session.setMaxInactiveInterval(30);

The servlet then forwards to a JSP page (intermediate1) which has a link to the second intermediate page (intermediate2). I don't do anything on the page for around 30 seconds (timeout interval) and then forward to the second jsp page (intermediate 2). Here I print the sessionID and it is NOT X. It is another value. How did this happen? Does the container automatically assign a session object to a JSP page if no session already exists? Kindly help.

Upvotes: 1

Views: 79

Answers (3)

Cafe
Cafe

Reputation: 61

Here is an interesting link I found on the web that answers my own question. FYI.

http://www.xyzws.com/jspfaq/can-i-prevent-the-creation-of-a-session-in-a-jsp-page/20

Upvotes: 0

Nikos Paraskevopoulos
Nikos Paraskevopoulos

Reputation: 40298

JSP spec (for JSP 2.1/JEE6 it is found in chapter "JSP.1.10.1 The page Directive") describes that the session implicit object is on by default, so that every call to a JSP will participate in an existing session/create a new session if needed. It can be turned off as:

<%@ page session="false" %>

Upvotes: 3

Vishal Gajera
Vishal Gajera

Reputation: 4207

Because of jsp implicit-object, then see one of them is 'session'.

So, jsp's implicate object always be there.

In your case, already current session object went off, but jsp api make it newly available.

Upvotes: 1

Related Questions