GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  J2EE  >  EJB
Go To First  |  Previous Question  |  Next Question 
 EJB  |  Question 49 of 175    Print  
Is it possible to share an HttpSession between a JSP and EJB. What happens when I change a value in the HttpSession from inside an EJB

  
Total Answers and Comments: 3 Last Update: May 22, 2007   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
September 11, 2005 08:20:13   #1  
RajaSekhar Reddy t        

RE: Is it possible to share an HttpSession between a JSP and EJB
You can pass the HttpSession as parameter to an EJB method, only if all objects in session are serializable.

This has to be consider as "passed-by-value", that means that it's read-only in the EJB. If anything is altered from inside the EJB, it won't be reflected back to the HttpSession of the Servlet Container.

The "pass-by-reference" can be used between EJBs Remote Interfaces, as they are remote references


 
Is this answer useful? Yes | No
April 16, 2007 08:07:37   #2  
k_yogi85        

RE: Is it possible to share an HttpSession between a J...
You can pass the HttpSession as parameter to an EJB method, however you should have all objects in session be serializable.This has to be consider as passed-by-value, that means that it’s read-only in the EJB. If anything is altered from inside the EJB, it won’t be reflected back to the HttpSession of the Servlet Container.

The pass-by-reference can be used between EJBs Remote Interfaces, as they are remote references.

While it is possible to pass an HttpSession as a parameter to an EJB object, it is considered to be bad practice in terms of object-oriented design. This is because you are creating an unnecessary coupling between back-end objects (EJBs) and front-end objects (HttpSession).

Better way to do it is, create a higher-level of abstraction for your EJBs API. Rather than passing the whole, fat, HttpSession (which carries with it a bunch of http semantics), create a class that acts as a value object (or structure) that holds all the data you need to pass back and forth between front-end/back-end. Consider the case where your EJB needs to support a non HTTP-based client. This higher level of abstraction will be flexible enough to support it.

 
Is this answer useful? Yes | No
May 21, 2007 21:27:07   #3  
Bhaktavatsalam Gani        

RE: Is it possible to share an HttpSession between a J...
It is not possible to pass the HttpSession as part of the EJB method parameter. Because it is not serializable. If we want to pass the session information we need to create another class that can hold all the session values in a serializable form.
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape