Hi,

Michael Pikounis a ?crit :

>
> I have a servlet that accesses a stateful session bean to perform a search
> in the database. The Servlet provides some search criteria and the bean
> executes the query, saves the results in its state and returns a list to the
> servlet.
>
> The servlet can now select one of the "things" returned to see more details.
> It passes the unique ID to the bean and the bean performs another query to
> find the details of the "thing" selected. It saves the details of the
> "thing" in its state and returns the details to the servlet.
>
> Everything works fine, and my bean provides some state that is persistent
> across HTTP requests. The servlet can maintain some information there (eg.
> The results of the query, the ID of the "thing" selected etc).
>
> The problem arises when the user decides to select the "thing" but in a new
> browser window. The new window will load the "thing" in the bean's state but
> the old window now "inherits" a state that is invalid (since in the old
> window the user has not yet selected anything).
>

Yes, the problem comes from the fact that "1 session = 1 client"... so here 1
browser = 1 session = 1 state
You would like to share that state between several browsers when they belong to
the same user. There is a way rather simple but expensive to do that: add an
entity been representing the user. In that entity you can store your "state" and
other data concerning your user.
Keep your stateful session, you will put a reference to the entity corresponding
to your user in its state.
The choice of such a solution depends a lot of what kind of users you have and
what they expect from your application...
(Any comment will be welcome :-) )

>
> I can think of a few ways to deal with this but I am not sure which is the
> best. The simplest is to make my bean stateless and maintain state in the
> servlet. Passing the results as hidden fields could be one way..
>

I  prefer to keep just a Handle to EJB stateful session in servlets, nothing
more. I don't know if it is the best way.

>
> Michael
>
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff EJB-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to