File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Session Handling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Session Handling" Watch "Session Handling" New topic

Session Handling


Joined: Nov 13, 2002
Posts: 6
Hi All,
We are using session cookies to maintain user information. We have a 'Logout' button, when clicked will call session.invalidate(); method to close the session.
The question is if the user clicks on the back button and clicks on the logout button again, the server throws the following jasper exception.
javax.servlet.jsp.JspException: No bean found under attribute key UserSessionObj
javax.servlet.jsp.JspException: No bean found under attribute key UserSessionObj
at org.apache.struts.taglib.logic.CompareTagBase.condition(
at org.apache.struts.taglib.logic.EqualTag.condition(
at org.apache.struts.taglib.logic.ConditionalTagBase.doStartTag(
at org.apache.jsp.plainHeader_jsp._jspx_meth_logic_equal_0(
at org.apache.jsp.plainHeader_jsp._jspService(
at org.apache.jasper.runtime.HttpJspBase.service(
If anyone knows how to handle this, we would appreciate it.
Asher Tarnopolski
Ranch Hand

Joined: Jul 28, 2001
Posts: 260
hey, i would think about doing something like this in the code called after the logout button is pressed:

Asher Tarnopolski

Joined: Nov 13, 2002
Posts: 6
Hi Asher Tarnopolski,
Thanks for the mail. Infact I have tried various options like putting the code in a if<statement> and try { } catch() block. It does not work.
What we are working on the web front is we are currently using struts framework. The web.xml has a listener class which has the session object. How do we make changes for it to recognise the session is invalid and redirect to login.jsp?
Thanks in advance.
web.xml content:
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please edit your profile and select a new name which meets the requirements.
Asher Tarnopolski
Ranch Hand

Joined: Jul 28, 2001
Posts: 260
hey, i see it's about struts i never worked with...
try struts forum!
does your session object implements HttpSessionActivationListener ? you can try to make sessionWillPassivate() method setting a cookie on user's machine. the logout button can check if this cookie is present. if it is- redirect to login page...once more, i don't have any idea about struts, so it's probably just a bla bla bla
[ November 26, 2002: Message edited by: Asher Tarno ]
Mark Stein
Ranch Hand

Joined: May 20, 2002
Posts: 75
I know you tried several versions of conditional statements.... have you tried putting your bean initialization tags in a conditional test for the session? It looks like your beans are trying to initialize but the info is gone.
I agree. Here's the link:
subject: Session Handling
It's not a secret anymore!