How do you share session objects between servlets and JSP?

anil chakravarthy

Sharing sessions between a servlet and a JSP page is straight forward. JSP makes it a little easy by creating a session object and making it availabe already. In a servlet you would have to do it yourself. This is how:

//create a session if one is not created already now
HttpSession session = request.getSession(true);
//assign the session variable to a value.
in the jsp page this is how you get the session value:
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact