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 Test for Session 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 "Test for Session" Watch "Test for Session" New topic
Author

Test for Session

Surest Uncle
Greenhorn

Joined: May 23, 2008
Posts: 1
How do I test for Session either open or closed using javaScript in a JSP?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60759
    
  65

"Surest Uncle", please check your private messages for an important administrative matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60759
    
  65

What do you mean by "open" or "closed" session?

If you are in a JSP, there will be a valid session. Are you trying to discover if the previous session has expired and you are in a new one?
Ali Khalfan
Ranch Hand

Joined: Nov 03, 2007
Posts: 126
don't think you could use javascript to access a session variable, why not store some variable in a session and then display it on the page somewhere..if it shows null then you'll know
Prasad Tamirisa
Ranch Hand

Joined: Mar 26, 2007
Posts: 130
This is also one of the ways, but not using java script.

Use reqeust.getSession() in a scriptlet and find out if the session is dead or active.
[ May 24, 2008: Message edited by: Prasad Tamirisa ]

Regards,
Durga Prasad
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Test for Session
 
Similar Threads
When is a HttpSession object created by the Web Container
Checking for Session Timeout
Struts and cactus please help
Posting session variables in single JSP page
click button to clear session