Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Navigation after a ServletFilter  RSS feed

Darth Heizenberg
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to figure out how to approach this problem in JSF.

I have an application, guarded with a ServletFilter (using NTLM authentication with jCIFS) that's checking for an authentication token in the session. If the token is absent, the browser pops up a login box and lets the user enter credentials.

At this point the filter allows the request to proceed to the requested URL (/index.jsp) that forwards to the first jsf page in the application. The trouble is that I can potentially have more than one 'first' or 'entry' page... and this is decided by the user's role.

I want to be able to intercept the request after the Authentication Filter and depending on the user's role (retrieved in their credentials) I want to forward them to one of two jsf pages. For example, one page for admins, and a different page for non-admins.

I doubt if I want to handle this with another filter... since filters should really call the next chained filter on the stack. Additionally, I may want to add more filters in the chain at some point in time.

As I write this, I can envision one way of doing this. Stuff an attribute in the session and have the index.jsp page behave as the navigation controller... i.e. instead of having the standard <jsp:forward page="/pages/home.jsf" />, I could have something like <jsp:forward page="/pages/${an_attribute_in_the_request}.jsf" />.

Is this doable with an Action/ActionListener mechanism(or any other event mechanism) of some sort? Is there any other JSF construct that can help me do this? It needs to be called before the JSF navigation handler has already dispatched the request to the entry page specified in the web.xml.

It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!