Can JSP and EJB share httpsession? Can the content in the session be changed in EJB?
Source: Internet
Author: User
I can see some netizens mentioned this problem and asked for more information. In fact, both of these questions have positive answers, but it is best not to do so.
If all the objects in the session are serialized, you can pass httpsession as a parameter to the EJB method. In this way, the value is passed, which is equivalent to the fact that the httpsession is read by itself, if the session value is changed in EJB, The httpsession In the servlet container will not be affected, but because the remote interfaces of EJB use remote reference, that is, reference transmission, therefore, it is possible to pass httpsession as a parameter to the EJB object, but this is against the object-oriented principle, in this case, an unnecessary dependency is created between the EJB and the front-end httpsession, in this case, ejbs also depend on HTTP-based clients (ejbs may also serve non-HTTP clients). In fact, instead of passing an entire httpsession object to ejbs, it is better to create another object with a similar structure, and then return to the client after processing the EJB.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.