This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session tracking

 
Sean Thornton
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSF is built over Servlets/JSP. It uses HttpSession only.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic