• Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB - access existing stateful session bean  RSS feed

 
Antonio Foglia
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everibody
I have a stateful session bean that initializes a Collections.synchronizedList, I add products to the list and check the list, it works(all during the same session). But when I restart the browser it doesn't show me the list.

After watching the console I have discovered that the bean is created again.
In my code i can access my bean only if i'm in the current http session.. and it doesn't work properly
Here is the code in my Servlet:



if i can't find my bean i instantiate a new one via lookup..
but how can i access an existing bean?
without creating a new one each http session?

 
Prajakta Acharya
Ranch Hand
Posts: 138
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since the stateful bean is stored in session, it itself means it is meant for the current session of any user.
You cannot expect to get the bean if the session is newly created.
 
Antonio Foglia
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prajakta Acharya wrote:Since the stateful bean is stored in session, it itself means it is meant for the current session of any user.
You cannot expect to get the bean if the session is newly created.

Can i use javax.servlet.http.Cookie to save mi session data?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!