File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Android Security Essentials Live Lessons this week in the Android 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: 60804

"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

Joined: Jan 10, 2002
Posts: 60804

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
Similar Threads
Checking for Session Timeout
When is a HttpSession object created by the Web Container
Struts and cactus please help
Posting session variables in single JSP page
click button to clear session