• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Stateful Session bean

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a stateful session bean that I want to store the userid and password in. In a servlet I assign the values to an instance variable, so that I can access them later.
I am doing this so that the user logs into the database as themselves (audit purposes) when doing a transaction.
So, I want the connection object to use the information from the stateful session bean to obtain the userid and password.
At that time, I need to get a reference to the already existing stateful session bean. When I do a look up with a create(), the values are null in the instance variables.
How do I access the session bean after it has been created without the benefit of storing the handle?
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In order to use an existing stateful session bean you must have a reference. Now, for a web application, you need to store the reference somewhere in between HTTP requests and that somewhere is usually HttpSession. This, in turn, requires you to use a handle (you can try storing non-serializable objects into HttpSession but you're playing russian roulette if you do that... In a clustered environment, this is not even remotely possible because the container definitely replicates session state somewhere and thus serializes the HttpSession).
 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does this mean that I cannot store any of the EJB references(home/remote interface) or their handles in a HttpSession Object in both single and clustered environment?
 
Ranch Hand
Posts: 8946
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Vish Kumar:
Does this mean that I cannot store any of the EJB references(home/remote interface) or their handles in a HttpSession Object in both single and clustered environment?


You can store Handle in HttpSession.
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at this article. Then consider an approach whereby you have an object that returns the reference, which is stored in a transient variable. If the reference isn't there (e.g. after failover) then recreate the reference from the Handle.
Kyle
 
What a show! What atmosphere! What fun! What a tiny ad!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic