Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / JavaBeans / November 2004

Tip: Looking for answers? Try searching our database.

Problem with Session Beans state

Thread view: 
Dj Frenzy - 29 Nov 2004 15:16 GMT
Hi, I'm currently making a session bean, which will eventually act as
a Shopping Basket.

I have implemented the bean so that it just accepts a string (which
will eventually be an object reference), and the user can add and
remove strings.

Unfortunately, if I access the same bean from another machine and
create an instance of the session bean, they are shown the same
contents as from the other machine.

The session bean type is set to stateful (and I have tried stateless).
Can anyone point me in the direction of the problem please?

Cheers,
David
John C. Bollinger - 29 Nov 2004 16:45 GMT
> Hi, I'm currently making a session bean, which will eventually act as
> a Shopping Basket.
[quoted text clipped - 9 lines]
> The session bean type is set to stateful (and I have tried stateless).
> Can anyone point me in the direction of the problem please?

First, you are probably using the wrong technology for what you're
trying to do.  If you want to support a large number of concurrent
baskets then you want to maintain basket state either

(1) At the servlet level, in custom objects (possibly normal JavaBeans)
stored with (HTTP) session scope, or

(2) In a backend database, accessed via a stateless session bean or,
possibly, entity beans.

I would shoot for (1) if you can, as (IMO) EJBs are to be avoided except
where you _need_ their particular strengths (transactionality,
container-managed security, distributability, etc.).  Where you need
EJBs, however, embrace them.  Also, do not be confused by the name
"session bean" -- the "session" part is completely unrelated to the kind
of client sessions managed by the front end in a typical web application.

If you insist on carrying on with your current design then you may find
that clearing out the basket state in the bean implementation's
ejbRemove() method solves the immediate problem.  If not, then, your
client interface is probably using the same session bean instance for
multiple clients (see above comments about sessions).

John Bollinger
jobollin@indiana.edu
Dj Frenzy - 30 Nov 2004 11:42 GMT
Cheers John.

http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Session2.html

I found this this tutorial pretty helpful also.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.