I have an internal website, split into several web applications.  A problem
has been co-ordinating a UserDataBean across the sessions for each app, so
that the user's preferences change across all apps simultaneously.

Here's the tag that puts a UserDataBean into the session; it's at the top of
all pages:

<jsp:useBean id="user" class="iris.intranet.UserDataBean" scope="session">
    <jsp:setProperty name="user" 
                 property="userName" 
                    value="<%= request.getRemoteUser( ) %>" />
</jsp:useBean>

The body should be executed only if there is no bean attached to 'user' in
the session, and that's what appears to happen.

The co-ordination problem was solved by having each bean register itself
with a singleton that dispatches propertyChanged events to other beans for
the same user.  I created a reporting function for the singleton to inspect
it, and got this:

    Number of UserDataBeans listening: 3
    Listening sessions:
        89140B58A732CF2989E5F3D9D7D58AA3 [Intranet]
        1E8628A77789A26C49AB80AA3B0B8665 [Project Template]
        1E8628A77789A26C49AB80AA3B0B8665 [Intranet]

[Intranet] is the contextName of the root app; [Project Template] is the
name of the app that is a template for other apps.  Notice that there are
three beans, but only two sessions.

The session starting 8914 is initialized on hitting the home page, and a
bean is created for it.  The session starting 1E86 is initialized on first
hitting the template app, and a bean is created for it.  My question is
about the second bean created for the session starting 1E86.

Every page uses <c:import url="/includes/mainMenu.jsp" context="/"> to grab
mainMenu.jsp from the root context; mainMenu has the same <jsp:useBean> tag
as I listed above.  What's apparently happening is that, since the import is
cross-context, mainMenu is being processed as being in the root context, not
the template context (as it should be, I believe).  However, the session to
which that bean is attached is the Template session.  In other words, the
template session is going cross-context.

At the point the import is executed, both sessions already have a
UserDataBean attached to 'user' in the session.  So why is a third created?
In either session, and in either context, the bean is already initialized
and attached.  The index page of the root app also imports mainMenu.jsp
locally, but doesn't create a bean in that case (the order of the beans
above is necessarily the order in which they were created; the third,
unnecessary bean was only created after the cross-context import).  

This isn't a problem, per se, just a strange behaviour that I would like to
understand.  Any insight is appreciated.

Justin

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to