File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

private variable holds value when returning to action

 
brian welter
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been every time I revisit this issue.


I have a base action support class that all my application actions extend....



I alter "stuck variable" in numerous actions that extends MyActionSupport, I set by calling it's setter.



Now everytime I returun to the DisorderAction, the value of stuckvariable is "wtf mate" before I even set it. Basically I need to clear the user session and clear a bunch of values across the entire app, but no matter what I do, it remains.

I've tried numerous ways to clear the session:
e.g. ((org.apache.struts2.dispatcher.SessionMap) ActionContext.getContext().getSession()).invalidate();

I must be missing something terribly obvious with the scope of that variable. Please help!
 
Jesus Mireles
Ranch Hand
Posts: 122
IntelliJ IDE Java Mac
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The scope is not session so the session.invalidate will not do anything.

Is this Struts1 or Struts2? In Struts1 you only get one instance of an action class. Struts2 creates an instance per request of an action.

-Jesus M.
 
brian welter
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using Struts2, 2.1.8 specifically.

Some other details on the project...

I'm also using Spring 2.5.6 for dependency injection ... so spring is set up as the default context loader.

Here's the web.xml


I'm also using Freemarker for the presentation layer although I don't think that could possibly cause this.
 
Jesus Mireles
Ranch Hand
Posts: 122
IntelliJ IDE Java Mac
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know spring as well as I know struts.

What I can tell you is that stuts 2 does not behave this way out of the box. I would probably imagine that your spring configuration might be the culprit.

JM
 
brian welter
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You were absolutely right...spring was the culprit...

I was referencing a spring bean for my actions so I could inject my manager classes easily. I simply needed to set the scope of the action beans to prototype and everything is working perfectly now.

Thanks for your time!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic