struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexis Pigeon" <>
Subject [S2] How to keep a reference to a bean without using a session scope?
Date Tue, 10 Apr 2007 07:00:17 GMT
Hi all,

My application uses a bean to store a collection of values to display
in a select input. Since the generation of this collection is
time-consuming, I set this bean to a session scope, and using the
following code :

in jsp:
<%@ taglib prefix="s" uri="/WEB-INF/struts-tags.tld" %>
<s:set name="myCollection" value="myCollection" scope="session"/>

in the Action (implementing Preparable and ServletRequestAware):
private Vector myCollection;
public Vector getMyCollection() {
    return myCollection;
public void setMyCollection (Vector v) {
    this.myCollection = v;
public void prepare() {
    setMyCollection( (Vector)

This works perfectly as expected, as long as there is only one
instance of the application launched at a time in the same browser
(using Firefox or IE7 tabs for example). In that case, the bean is
shared between the different instances, which is problematic since its
content depends on previous data input.

I tried to change the scope of the bean, using "page" or "request".
Passing the bean from the Action to the jsp is ok, but I can't get the
jsp to pass it back to the Action.

Is there another interface I should implement in the Action, or
another tag I should use in the jsp? Or maybe there is a way to force
the creation of a new session when opening another instance of the

Thank you all for the help,

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

View raw message