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 / General / November 2005

Tip: Looking for answers? Try searching our database.

Session Beans

Thread view: 
Sachin - 04 Nov 2005 11:18 GMT
I am implementing a shoping cart apllication using ejb stateful session
beans as an excercise in learning ejb. I use a jsp page as the client.
I use sun system application server. My problem is, when the web server
use the same JSP instance to handle multiple requests for the same jsp
page, same state of the bean instance may be shared among multiple
clients. So this can produce wrong results and how i avoid this? Please
help me.
Bryce - 04 Nov 2005 16:43 GMT
>I am implementing a shoping cart apllication using ejb stateful session
>beans as an excercise in learning ejb. I use a jsp page as the client.
[quoted text clipped - 3 lines]
>clients. So this can produce wrong results and how i avoid this? Please
>help me.

Strange, shouldn't be happening... What does your JSP page look like?
are your variables static? Are you putting the beans in application
scope instead of session?

--
now with more cowbell
HalcyonWild - 07 Nov 2005 12:20 GMT
> >I am implementing a shoping cart apllication using ejb stateful session
> >beans as an excercise in learning ejb. I use a jsp page as the client.
[quoted text clipped - 3 lines]
> >clients. So this can produce wrong results and how i avoid this? Please
> >help me.

> Strange, shouldn't be happening... What does your JSP page look like?
> are your variables static? Are you putting the beans in application
> scope instead of session?

I too got thinking about it.

Only one instance of the compiled servlet class of the JSP runs in the
container's memory. So, multiple requests to the server would mean, the
same java class(of the jsp) executing, via multiple threads. If the Jsp
has data members, they can be corrupted. Even though, different
stateful EJB exist for different requests, the JSP instance remains the
same.

Is it a good practice to avoid private data members in JSP and
servlets. I have never seen anything like that. ( Looking at existing
code gives a very good idea of how to use stuff ).

What if your JSP has private data members? Will it have every chance of
inconsistent data.

By the way, to be safe, do not call the EJB directly from the JSP. Use
a delegate, a simple java class instantiated for every call to the JSP,
which in turn handles the EJB, and returns data back to JSP.


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



©2009 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.