File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Handling HttpSession Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Handling HttpSession " Watch "Handling HttpSession " New topic

Handling HttpSession

S Babs

Joined: Apr 16, 2003
Posts: 18
Where do i handle HttpSession in MVC architecture?
Brian R. Wainwright
Ranch Hand

Joined: Aug 12, 2003
Posts: 92
What do you mean by "handle?"
Basic functionality is....
You can obtain the current HttpSession object from the request object through:
HttpSession session = request.getSession(true);
specifying "true" will create a new session if one does not already exist.
You can put stuff into and get stuff out of your session thusly:
session.setAttribute("key", value);
The key in the set method has to be a String, but the value can be any object.
Thus you can get your session and its attributes anyplace you can access the request object. (mostly on a JSP or in a Servlet).
[ August 18, 2003: Message edited by: Brian Wainwright ]
I agree. Here's the link:
subject: Handling HttpSession
It's not a secret anymore!