How to get one servlet session attribute in another servlet

I have two servlets in my 2nd project, which is called from the first servlet. Im creating an http session in the first servlet and setting some attributes for this session object. How to get the values ​​of these attributes in the second servlet?

Thanks in advance.

+3
source share
1 answer
Object value = request.getSession().getAttribute("nameOfTheAttributeUsedInTheFirstServlet");

If two servlets are in the same webapp, they use the same session context, and the session is the same for both servlets. Of course, remember that a session is limited to a specific user.

+3
source

All Articles