aspose file tools*
The moose likes Struts and the fly likes Token session Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Token session Problem" Watch "Token session Problem" New topic
Author

Token session Problem

vik ar
Ranch Hand

Joined: Jul 31, 2009
Posts: 104
Hi. I have some functionality in my site which allows a member to login and logout of their account. When the user clicks the logout link the following code is executed to destroy the session

I have stepped through in debug and this code executes fine. However when an attempt is made to display the resulting page I get the following error

When I take the following code out of the resulting jsp the error does not happen.

I am guessing this issue is being caused by the token (which I am using to prevent double submits). To get around this I am thinking of not using the token and instead introducing some javascript to disable the button once its been clicked. I know if the client has js turned off there is a chance of double submit, but the functionality is read only on the db, so I am not too concerned. However at the same time it feels like a fudge and would like to understand and fix the issue correctly. Over to you
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You're trying to invalidate the session then turn around and use it--pick one.
vik ar
Ranch Hand

Joined: Jul 31, 2009
Posts: 104
then i will use js for search functionality. cheers
Shriram Pandit
Greenhorn

Joined: Apr 08, 2011
Posts: 11
Hi David /Vik I am also getting the same error

SEVERE: Error creating HttpSession due response is commited to client. You can use the CreateSessionInterceptor or create the HttpSession from your action before the result is rendered to the client: getAttribute: Session already invalidated
java.lang.IllegalStateException: getAttribute: Session already invalidated
at org.apache.catalina.session.StandardSession.getAttribute(StandardSession.java:1165)
at org.apache.catalina.session.StandardSessionFacade.getAttribute(StandardSessionFacade.java:122)
at org.apache.struts2.dispatcher.SessionMap.get(SessionMap.java:163)
at org.apache.struts2.dispatcher.SessionMap.put(SessionMap.java:181)
at org.apache.struts2.util.TokenHelper.setToken(TokenHelper.java:71)
at org.apache.struts2.components.Token.buildToken(Token.java:114)

Please guide me . As I didnot understand the answer you gave to Vik

Really Appreciate the help.

Note: I am also using Token Session interceptor in my code and getting this error while loggin out on call of getServletRequest().getSession().invalidate();
Shriram Pandit
Greenhorn

Joined: Apr 08, 2011
Posts: 11
Hi David understood what you said.

Thanks Now error is not getting displayed becuase of removal of <s:token/> from result page

Really appreciate it.
 
Consider Paul's rocket mass heater.
 
subject: Token session Problem