struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig McClanahan <>
Subject Re: session and request scope
Date Mon, 14 Mar 2005 06:14:01 GMT
On Thu, 10 Mar 2005 23:56:08 +0100, G√ľnther Wieser
<> wrote:

> as long as you don't have a clustered environment or session persistence
> enabled in your servlet container, there shouldn't be much difference in
> adding an object to a session or request.

That is almost, but not quite, accurate.

The physical act of storing and retrieving the object into request
scope or session scope can have a minor performance difference (in
request scope, the container doesn't have to synchronize because it
knows only one thread is accessing the underlying HashMap).  The more
important issue, though, is that session scope attributes will occupy
memory space in between HTTP requests (request scope attributes become
eligible for garbage collection as soon as the request completes) --
that's fine if you need the underlying information, but flagrantly
wasteful if you do not.  On apps with lots of users, this can become a
mission critical issue.

For a developer, though, you should train yourself to good habits in
the first place -- use request scope for *everything* unless it
absolutely must be saved, on the server side, in between requests from
the same user.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message