[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: session variables in struts
As an alternative, consider ignoring the problem.
For most systems supporting a small number of users,
best-effort session cleanup is easiest. For example,
if your wizard has a cancel button, clear the session
when it's clicked. If the user exists the wizard some
other way, just don't worry about it, but always be
sure to reset the session when the user starts the
wizard over again.
I know this doesn't sound very elegant, but I think
it's smart whenever it's viable. Memory is cheap, but
software development and maintenance time is not.
Envelope calculation: suppose you have 50 unexpired
sessions in memory at any time. Even if you store a
ridiculous 100K of state in the session, that's only
5MB wasted. Most app servers have an extra 5MB to
spare, but most software projects do not have an extra
two weeks to build, test, and maintain better session
cleanup.
Of course, if you're planning to support hundreds or
thousands of concurrent users you'll need to spend
some real time solving this problem another way, such
as Scott's solution.
--- "Scott P. Smith" <ssmith@scott-smith.com> wrote:
> I solved this problem once by having two types of
> session objects: permanent
> and temporary.
>
> All my permanent session objects had names that
> started with an underscore
> '_'. My wizard session objects, like the one you
> specified, where temporary
> session objects (without the leading underscore).
>
> Then I had my main menu action class (I had a single
> action class that
> proceed all main menu actions) clear all session
> objects whose names did not
> start with an underscore. That's basically what you
> are suggesting, I'm
> just filling in the details for the way we
> implemented that approach.
>
> There's probably a better way (there usually is),
> but this is what we did.
>
> Scott
>
> ----- Original Message -----
> From: "Poorav Chaudhari" <pooravc@yahoo.com>
> To: <ajug-members@ajug.org>
> Sent: Monday, March 10, 2003 4:37 PM
> Subject: session variables in struts
>
>
> > I am developing a web application using the struts
> framework on tomcat.
> Now, I
> > have one form that spans multiple pages. So to
> enable free user navigation
> > between pages (1st to 3rd to 4th to 2nd....) and
> maintain the form values
> i
> > store the form information in a form object with
> session scope. if the
> user,
> > after completing the 4 pages of the form presses
> save, i save the info
> into the
> > database and remove the session attribute from
> memory. but my problem is
> what
> > if the user decides in the middle of filling out
> the form to go to some
> other
> > page, and clicks on one of the other links. Now
> the session variable is
> still
> > in memory without any use for it. one way around
> this i see is to remove
> all
> > session variable my application creates within
> each action class except
> for the
> > ones that are required for that particular page.
> But this i don't see a
> > practical or an elegant solution. Can some one
> please help me with this
> > problem. suggestions and/or references to sites
> with helpful info on this
> will
> > be greatly appreciated.
> >
> > Thank you.
> >
> > =====
> > Poorav Chaudhari
> >
> > __________________________________________________
> > Do you Yahoo!?
> > Yahoo! Tax Center - forms, calculators, tips, more
> > http://taxes.yahoo.com/
> >
> >
>
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/