aspose file tools*
The moose likes Struts and the fly likes Session invalidation - getModel called from JSP? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Session invalidation - getModel called from JSP?" Watch "Session invalidation - getModel called from JSP?" New topic
Author

Session invalidation - getModel called from JSP?

Santosh Sb
Greenhorn

Joined: Nov 04, 2009
Posts: 10
I am working on a struts 2 application that takes credit card and ach payments. The application is ModelDriven, all the data entered on the screens are saved in a domain model that's in session.

The requirement is that once the payment service has been called successfully, the session should be invalidated and then the user be shown the confirmation screen with confirmation number and other details.

Problem is, in the last action class which loads the confirmation screen, I invalidate the session, and then route to the JSP. But the JSP for some reason calls the getModel method on the action which tries to load the domain object from session. Since the session is already invalidated, I am getting something like java.lang.IllegalStateException: getAttribute: Session already invalidated. On the browser, I see a Stream is already closed exception.

Looking at the stacktrace, there are a few <s:text tags on the JSP that inturn call the getModel. Why is the s:text calling getModel?

Can the gurus please point out if I am missing something, or doing something wrong? Thanks bunches!
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9280
    
  17

Hi Santosh, welcome to javaranch.

Can you show us the code of your JSP page. Right now there isn't enough information to guess what the problem is...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Santosh Sb
Greenhorn

Joined: Nov 04, 2009
Posts: 10
Thanks for responding Ankit.

This is action class that does session invalidation




The Base Action class has getModel method that loads the domain model from session into the action classes. I added the try catch block in the getModel method otherwise the JSP throws the IllegalStateException error



The JSP uses s:getText to display dynamic text either from Action class attributes or from the resource bundle



It blows up right on the first s:text

Any ideas? Thanks again!
Lorand Komaromi
Ranch Hand

Joined: Oct 08, 2009
Posts: 276
Santosh Gyrations wrote:
The JSP uses s:getText to display dynamic text either from Action class attributes or from the resource bundle



As far as I know, s:text can load text from resources only, you'd have to use s:property, for instance, to display strings from your action class.

Are you sure that getModel() is called because of the s:text tags..?


OCJP 6 (93%)
Santosh Sb
Greenhorn

Joined: Nov 04, 2009
Posts: 10
Yes Lorand. I will post the exception stack trace tomorrow, but I pretty sure somewhere in there I saw the s.text call from the jsp page.

Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session invalidation - getModel called from JSP?
 
Similar Threads
IlegalStateException
Clean-up objects in session.
Some questions about the Scoped Model Driven interface of Struts 2
Post-Redirect-Get pattern with Struts 2 ModelDriven action?
Session.invalidate() and Logout