You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Kris Schneider <kr...@dotech.com> on 2002/09/21 02:37:12 UTC

Re: How to remove ActionForm with session scope from the session object

True, you probably don't want to keep your forms in session scope just
for kicks. But assuming they're there for a reason, here's one
(untested) way you might be able to track them down (at least for
1.0.2).

ActionMappings mappings =
(ActionMappings)context.getAttribute(Action.MAPPINGS_KEY);
String[] paths = mappings.findMappings();
for (int i = 0, n = paths.length; i < n; i++) {
  ActionMapping mapping = mappings.findMapiing(paths[i]);
  if ("session".equals(mapping.getScope())) {
    session.removeAttribute(mapping.getName());
  }
}

Of course, if you want to skip the mapping(s) for your current action
(set of actions), you'll have to test for the occurrence of it's (their)
path(s) within the loop, but you should get the idea...

Tiago Nodari wrote:
> 
>          isnt that what you get paid to figure out? jk, it is friday :))
> 
>          i really didnt get it, why would you have 10 objects in the
> session if you are no using them :))) jk , what I do is if I have an object
> in the session, when a user does a certain action like logout or something
> I remove certain objects, so in some actions I try to remove certains
> objects that i know might be in the session and are no longer needed, not a
> 100% effective, but its been working pretty well...
> 
>          tiago
> 
> At 02:48 PM 9/20/2002 -0500, you wrote:
> >I've a number of forms with session scope and I want to remove them from the
> >session object when I am no longer used them.  The trick is how to find out
> >when they are no longer being used?  For example, let say I've 10
> >actionForms associated with 10 jsp page.  If I am on page number 1
> >therefore, page 9-10 is not being used and I can just loop through it a
> >remove the corresponding actionForms from the session object.  If I am page
> >number 2 then I loop through page 1 and 8-10 and so on.  Is there a better
> >way for me to do this?  Thanks
> >
> >Hai Hoang
> >
> >
> >
> >_________________________________________________________________________
> >Introducing the all new and improved continental.com.  With a totally new
> >personalized design, it's the best place to go. Before you go.
> >
> >Continental Airlines. Work Hard. Fly Right.
> >
> >http://www.continental.com

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>