This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session problems with JSP on ServletExec, W2000
 
Similar Threads
session expiry
user ame from windows system!! got it
Post Does not Return new Values
How to determine if a session has expired...
detect hits to the jsp in a session