aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes how to deal with session if you have both servlet and EJB ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "how to deal with session if you have both servlet and EJB ?" Watch "how to deal with session if you have both servlet and EJB ?" New topic
Author

how to deal with session if you have both servlet and EJB ?

Fei Teng
Greenhorn

Joined: Feb 07, 2006
Posts: 4
if I only have servlet/jsp, I can use HttpSession to save the objects in there, easy. Now for the following scenarios---

1. servlet only talks to STATELESS session beans. In this case, I can just keep using the HtppSession I have in the servlet because the EJB part doesn't need any session information, is that right ?

2. servlet talks to STATEFUL session bean and stateful session beans talk to entity beans. Then how to I "pass" the HttpSession I have in the servlets to those STATEFUL session beans ? This case often happens when I let users pick certain thing on web pages and these info is stored in the httpsession, then session beans are called, how to handle the session now ?
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

2. servlet talks to STATEFUL session bean and stateful session beans talk to entity beans. Then how to I "pass" the HttpSession I have in the servlets to those STATEFUL session beans ? This case often happens when I let users pick certain thing on web pages and these info is stored in the httpsession, then session beans are called, how to handle the session now


When you access the SFSB(Stateful Session bean)for the first time store the Handle of the business (EJBObject) in the HttpSession. When the same user makes another request and the SFSB needs to be invoked retrieve the handle from the Httpsession, get the EjbObject from the handle and invoke the method.


Groovy
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: how to deal with session if you have both servlet and EJB ?