Hello all!

I was wondering if there is a standard way to deal with the following issue:

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).

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..

Alternatively, I could have my bean clone itself when a method that modified
existing state is executed. This way the servlet can create the bean, add to
its state, but cannot modify the state. In the example above, the "new"
window would add to the bean's state, but when the old window asked for a
different "thing" to be selected, the bean would clone itself, and the new
instance would be returned to the old window. Eventually, unused beans would
be removed() by the application server.

I hope this was clear :-) Any ideas?

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".

Reply via email to