Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6587803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:57:54+00:00 2026-05-25T16:57:54+00:00

Framework: JSF 2.0. My problem : I have a page, called login.xhtml. Whenever someone

  • 0

Framework: JSF 2.0.

My problem: I have a page, called login.xhtml. Whenever someone view that page, it invoked a filter, called Authentication filter. The filter will check, if user already loged in, it will be redirected to default based on user’s role (for example: Admin will go to “admin/admin.xhtml”, student will be redirected to “user/user.xhtml”).

My solution: Using the JSF Navigation

My config:

faces-config.xml

<navigation-rule>
    <from-view-id>*</from-view-id>
    <navigation-case>
        <from-outcome>AD</from-outcome>            
        <to-view-id>/admin/admin.xhtml</to-view-id>
    </navigation-case>
    <navigation-case>
        <from-outcome>US</from-outcome>            
        <to-view-id>/user/user.xhtml</to-view-id>
    </navigation-case>
</navigation-rule>

The redirection using navigation:

public static void redirectUsingNavigation(String from, String outCome) {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    facesContext.getApplication().getNavigationHandler().handleNavigation(facesContext, from, outCome);
}

My question:

  1. When i run the redirectUsingNavigation(“*”,”AD”) or redirectUsingNavigation(null,”AD”), it does not redirect me to admin.xhtml (i’m still on login.xhtml). How to fix this?
  2. Any framework support me on this problem?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:57:55+00:00Added an answer on May 25, 2026 at 4:57 pm

    That code is not redirecting at all. It’s just forwarding the request. It’s just using the same request object for a different target page). A real redirect instructs the browser to send a new request on the given Location header. You see this change being reflected back in browser address bar.

    You need to either add faces-redirect=true parameter to the outcome to trigger the redirect (this is particularly useful if you’re using implicit navigation instead of verbose navigation cases):

    navigationHandler.handleNavigation(facesContext, from, outCome + "?faces-redirect=true")
    

    Or add <redirect/> to the navigation cases if you want them to always take place:

    <navigation-rule>
        <from-view-id>*</from-view-id>
        <navigation-case>
            <from-outcome>AD</from-outcome>            
            <to-view-id>/admin/admin.xhtml</to-view-id>
            <redirect/>
        </navigation-case>
        <navigation-case>
            <from-outcome>US</from-outcome>            
            <to-view-id>/user/user.xhtml</to-view-id>
            <redirect/>
        </navigation-case>
    </navigation-rule>
    

    Last but not least, you need to ensure that handleNavigation() is called before the response is committed, otherwise it won’t work at all and your server logs would be littered with IllegalStateException: response already committed errors. You can make use of <f:event type="preRenderView"> to invoke a bean action before the response is committed.

    See also:

    • jsf navigation question
    • Hit a bean method and redirect on a GET request
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read somewhere the view ids used by JSF framework have a happy side
In a JSF application, we have the directory hierarchy: webapp xhtml login.xhtml main.xhtml search.xhtml
I have a problem for mapping my servlet with my Java Server Page, using
In JSF MVC framework who is Model, View, and Controller?
I have a form page that has an inputText field that accepts a date.
I am new to JSF framework and Facelets as view, I am stuck with
I have J2EE web application which uses JSF framework. Now I am trying to
I have a JSF form that consists of a grid and some detail fields.
I have a web application in which we use JSF framework. I have been
AVFoundation.framework is not where the documentation says it should be. I have iPhone SDK

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.