Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sessions in EJB and JSP/Servlets

 
kiran mahavir
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
may i know the difference between the sessions in ejb and in JSP/Servlets. Are they used for same purpose ? If not under what circumstanes do we go for them.
Thanking in advance
with regards
kanth
 
Manjunath Subramanian
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi Kiran,
Your question co-incides with java.sun.com's
"QUESTION OF THE WEEK".
http://developer.java.sun.com/developer/qow/index.jsp
But i would appreciate if somebody throws more light on this!!
thanks,
Manjunath
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18014
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A "session ejb" is NOT a session in the sense of being a centralized place for short-term data persistency the way a servlet/JSP session is. In fact, the Stateless Session EJB has no data persistency at all, while Entity EJBs are permanently persistent.
In other words, as far as user sessions are concerned, Sun would have been better off naming them "gummi-bear EJBs". I think their intent had actually been to mean "EJBs used BY a Session" (?)
 
Manjunath Subramanian
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi Tim,
I get only this point
The Stateless Session EJB has no data persistency at
all, while Entity EJBs are permanently persistent.

but not much regarding all the other points.
I have a vague idea about sessions w.r.t EJB's and the web
components,but i am not able to get to the exact difference
between them.
Can you explain this point a little more Tim?
thanks
Manjunath
 
ruilin yang
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My understanding is that in Servlet/JSP you can put data in the session object to persist the info for a session.
However, in EJB, if you use a stateless session bean you will not persist info when you jump between methods/pages within a log-in session.
Please comment more.
 
ranga 786
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in case of SessionBeans a well defined life cycle is there and the containere provides a lot of services which a jsp /servlet cant get from the webserver.
 
Matt Midcap
Sheriff
Posts: 440
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"ranga 786",
Thank you for your input on this subject.
Also, the Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic