aspose file tools
The moose likes JSF and the fly likes How to check if the user is logged in in JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "How to check if the user is logged in in JSF" Watch "How to check if the user is logged in in JSF" New topic
Author

How to check if the user is logged in in JSF

Ahmad Qatramiz
Greenhorn

Joined: Jul 02, 2006
Posts: 3
I need to know if the user is logged in, if not will be redirected to login page.

How can i do this?
Vassili Vladimir
Ranch Hand

Joined: Mar 08, 2007
Posts: 1585
Hi,

Store some token in the session object.

If that token (let's say isLoggedIn) is avaliable (which will be stored upon successful login), then the user is in.

Otherwise, do your normal redirection.

Regards,


Vassili ...
SCJP 5.0, SCWCD 1.4, SCJA 1.0
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 14491
    
    7

Actually, in most cases the mere existence of a session means you're logged in - depending on what you define as "logged in". However, to accurately test for a session, you should make sure that you call the get session method with the right option. Otherwise get session will create a session if one didn't already exist, so it would always say you were logged in, even if you hadn't authenticated or set up whatever session parameters your login process might initialize.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: How to check if the user is logged in in JSF
 
Similar Threads
session problem
why request.getRemoteUser() returning null
Identifying a user
Setting request parameter from interceptor and accessing in ActionClass
Costomize the jboss portal default page based on users