This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma 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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Test for Session" Watch "Test for Session" New topic

Test for Session

Surest Uncle

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

Joined: Jan 10, 2002
Posts: 63873

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

[Asking smart questions] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63873

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 ]

Durga Prasad
I agree. Here's the link:
subject: Test for Session
It's not a secret anymore!