I know this is a dumb question.
I have a servlet that creates a stateful session bean
Context ctx = getInitialContext();
TraderHome brokerage = (TraderHome) ctx.lookup("statefulSession.TraderHome");
// Give this trader a name
Trader trader = brokerage.create("Terry");
Once the sfsb does its thing the servlet returns some data. A subsequent call gets made to a different servlet (for the same logical person).
How can this second servlet instance find the previously created sfsb?
Does it do the same lookup/create as the original servlet did?
What prevents the stateful session bean from getting garbage collected?
Thx
Don't do a lookup for the second request.
After the first lookup store the 'Trader' instance in the session of the user.
For subsequent requests get 'Trader' from the session and use it without calling create again.