Win a copy of Design for the Mind this week in the Design 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
GenRocket Founder
Ranch Hand
Posts: 15302
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