Results 1 to 1 of 1
Thread: Learning Stateful session beans
- 09-07-2011, 11:45 AM #1
Member
- Join Date
- Feb 2011
- Posts
- 4
- Rep Power
- 0
Learning Stateful session beans
Hi
I am learning stateful session beans, and I need some help and/or explanation.
I created a very simple stateful bean.
Java Code:public @Stateful class AdderBean implements Adder { private int data=0; public int getData(){ return data; } public void addData(int d){ data = data+d; } }
I have some problems with this little test application. If i get the bean inside the doGet method its behave like a statless bean. It only contains the last inserted value. However if i get the bean in the constructor of the servlet it works like a singleton bean and if i test it in two different browser which maintains two different sessions I can modify only one value and it's shared between two browsers.
I want to increment the value in the bean through more then one call like it is a very simplified shoping cart bean.
How can i use this bean?
Should I have to put the bean reference into the Session object and get it for every call?
May i misunderstood the concept of the stateful session beans, I think i don not have to maintain session manually when I use enterprise beans.
Please, provide me a proper method or explanation.
Thank you for your help.
iwanabeguruLast edited by iwanabeguru; 09-07-2011 at 12:01 PM.
Similar Threads
-
stateful session bean pool size
By javakt in forum Enterprise JavaBeans (EJB)Replies: 1Last Post: 07-08-2011, 02:08 PM -
Stateful Session Bean
By Java Tip in forum Java TipReplies: 0Last Post: 11-29-2007, 12:39 PM -
Calling a Stateful Session bean in NetBeans
By JavaForums in forum NetBeansReplies: 0Last Post: 07-31-2007, 09:21 AM -
Introduction to Stateful Session Bean In NetBeans
By JavaForums in forum NetBeansReplies: 0Last Post: 07-31-2007, 09:21 AM
Bookmarks