Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Session Beans

Reply
Thread Tools

Session Beans

 
 
Sachin
Guest
Posts: n/a
 
      11-04-2005
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.

 
Reply With Quote
 
 
 
 
Bryce
Guest
Posts: n/a
 
      11-04-2005
On 4 Nov 2005 02:18:01 -0800, "Sachin" <> wrote:

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


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
 
Reply With Quote
 
 
 
 
HalcyonWild
Guest
Posts: n/a
 
      11-07-2005

Bryce wrote:

> On 4 Nov 2005 02:18:01 -0800, "Sachin" <> wrote:


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


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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
handy access to attributes of entity beans from session beans Torsten Schmeissel Java 0 04-29-2005 05:19 PM
Tomcat JSP session beans not being removed at the end of the session John Smith Java 2 07-15-2004 12:46 PM
Server side context for session beans TT \(Tom Tempelaere\) Java 1 01-29-2004 10:47 AM
Design Question: Session vs. Entity Beans MP Java 2 11-11-2003 07:09 PM
The difference between Session and Entity Beans? <see body> Kabal Java 0 07-22-2003 07:35 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57