• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Fei Teng
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic