This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF Suggestions Needed

 
Abiodun Adisa
Ranch Hand
Posts: 495
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am developing a JSF application where by the navigation is from PageA-->PageB-->PageC . At page A The user signs in. The problem is if a user decides to access Page B with out signing in I want the application to authomatically redirect to PageA so that this user can sign in .
Any Suggestions would be welcome
 
Dudley Dawson
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A filter should do the trick.
Google "Intercepting Filter Pattern"
 
James McCluskey
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you not just use standard servlet security for this?

[ August 26, 2007: Message edited by: James McCluskey ]
 
Vassili Vladimir
Ranch Hand
Posts: 1585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Check for a specific token in the session, if that token is not there, do the redirection, otherwise, do your normal work.

Get a reference to the current instance of the FacesContext, which you use to get an instance of the ExternalContext, which has a method named getSession() that references to the HttpSession object.

Let me know what happens with you ...

Best of luck ...
 
Vassili Vladimir
Ranch Hand
Posts: 1585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And one more thing, the ExternalContext contains a method named getResponse(), which actually is the HttpServletResponse, so you can use its sendRedirect() method to do the redirection.

Whenever the user logs in, use the HttpSession object to add an attribute in the session.

Best of luck ...
 
Abiodun Adisa
Ranch Hand
Posts: 495
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Vassili Vladimir:
Hi,

Check for a specific token in the session, if that token is not there, do the redirection, otherwise, do your normal work.

Get a reference to the current instance of the FacesContext, which you use to get an instance of the ExternalContext, which has a method named getSession() that references to the HttpSession object.

Let me know what happens with you ...

Best of luck ...


The idea Sounds interesting,I would try this and let you know

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic