Question :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? (EJB)
Answer :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-byvalue",
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 (1)" 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). Create a higher-level of abstraction for
your ejb's 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. (1) Core J2EE design patterns (2001)
www.interviewhelper.org is a hope for all the Job seekers. Users can find unlimited here. These range from technical to HR, from functional to behavioral. www.interviewhelper.org contains in the fields like Ajax,VB,Networking,Sharepoint,JEE,Perl,Javascript,Bioinformatics,Classic ASP,Unix,Linux,Accounting,Oracle DBA,Microprocessor,Bluetooth,jms,jme,.net framework,ABAP,ASP,ASP.net,Basic .net Framework,Interview Questions,C language,C++,database,Oracle,Java,PHP,LAMP,SAP etc.
Friday, March 13, 2009
Is it possible to share an HttpSession between a JSP and EJB? What
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment