wood burning stoves 2.0*
The moose likes JSP and the fly likes Session problems with JSP on ServletExec, W2000 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Session problems with JSP on ServletExec, W2000" Watch "Session problems with JSP on ServletExec, W2000" New topic
Author

Session problems with JSP on ServletExec, W2000

SAFROLE YUTANI
Ranch Hand

Joined: Jul 06, 2001
Posts: 257
I have a very simple JSP page that checks to see if the user is accessing the page from the context of a session and prints a message indicating that a session has been found. But I would think when I access the JSP from a new broswer that the session should not be found, but it is.
HttpSession session = request.getSession( false);
if( session == null){
print(No session found)
else {
print(Found session!)
}
The session should not be found on the first time accessing the page since no session was ever created. Anyone?
thanks
SAF
[This message has been edited by SAFROLE YUTANI (edited November 16, 2001).]
Tony Alicea
Desperado
Sheriff

Joined: Jan 30, 2000
Posts: 3222
    
    5
The JSP engine will create a session for the JSP. That's why session is one of the implicit objects found in the JSP.
It is in Servlets that the method request.getSession(boolean) is useful.


Tony Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
SAFROLE YUTANI
Ranch Hand

Joined: Jul 06, 2001
Posts: 257
I understand that. I know the implicit "session" object exists, but the problem with this is that the JSP will create a new session for you even if the client accesses the JSP without a session. I need explicit control over the session for my application, and I just determined how to do it...
Add this directive to the JSP and the implicit session object disappears...
<%@ page session="false" %>
SAF
 
jQuery in Action, 2nd edition
 
subject: Session problems with JSP on ServletExec, W2000