File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Session object in a JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Session object in a JSP" Watch "Session object in a JSP" New topic

Session object in a JSP

A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 980

If there is a jsp page that has a page directive disabling a session..

then how will the user's session be tracked....during the browsing of the application...

i.e. earlier pages and subsequent pages from this page..

Thanks in advance,
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

The session directive doesn't really 'disable' sessions.
It just instructs the JSP compiler not to generate code that would explicitly create a session in this JSPs generated servlet.

If any JSP, or servlet has code that calls getSession(), then a session object will be created and the application will track sessions.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 980
Thanks Ben!!!
Chetan Chauhan

Joined: Oct 03, 2006
Posts: 8
If you do not wish to use in-built Session features then you can use
either of the following two techniques

1. Use Hidden Fields
2. Use Cookies

Then there will be no need to write code for session tracking.
But ofcourse some different code has to be there to implement this.
I agree. Here's the link:
subject: Session object in a JSP
It's not a secret anymore!