my dog learned polymorphism
The moose likes JSF and the fly likes Session tracking Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Session tracking" Watch "Session tracking" New topic

Session tracking

Sean Thornton

Joined: Jun 18, 2002
Posts: 5
How does JSF maintain a session? I know that when working with the servlet API your supposed to call request.getSession(). Does JSF do this for you automatically?
Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
JSF is built over Servlets/JSP. It uses HttpSession only.

- Varun
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

Yes, JSF uses HttpSession, but doesn't give you transparent access to it. Everything in JSF is handled via the managed-beans. So if you want something stored in the session give the managed-bean session scope.

IF you just can't live without manipulating the HttpSession directly you can do:

session = (HttpSession)FacesContext.getCurrentIstance().getExternalContext().getSession();

you can also get things like the request and response objects as well from the external context.

GenRocket - Experts at Building Test Data
I agree. Here's the link:
subject: Session tracking
It's not a secret anymore!