Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
Is it possible to share an HttpSession between a JSP and EJB? What happens when I change a value in the HttpSession from inside
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?
✍: Guest
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-byreference" 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). 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.
2013-07-27, 1844👍, 0💬
Popular Posts:
interview.FYIcenter.com offers a collections of interview questions and answers for software and Web...
What is the difference between RegisterClientScriptBloc kand RegisterStartupScript? RegisterClientSc...
How to create a thread in a program? You have two ways to do so. First, making your class "extends" ...
How To Add Column Headers to a Table? - XHTML 1.0 Tutorials - Understanding Tables and Table Cells I...
In C#, what is a weak reference? Generally, when you talk about a reference to an object in .NET (an...