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

  • Home
  • SEARCH
  • 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 7834659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:16:13+00:00 2026-06-02T13:16:13+00:00

We have servlet filter which verifies couple of session variables before JSF view display.

  • 0

We have servlet filter which verifies couple of session variables before JSF view display. Some how when a navigation rule is invoked in bean using handleNavigation(…) method, filter is not being called. Am I missing anything? Any help would be appreciated.

Here is web.xml

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"
         version="2.5">

    <display-name>JSF</display-name>
    <description>
        JSF
    </description>
    <filter>
        <filter-name>myFilter</filter-name>
        <filter-class>myFilterClassPath</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>myFilter</filter-name>
        <servlet-name>Faces Servlet</servlet-name>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
        <dispatcher>ERROR</dispatcher>
    </filter-mapping>

    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
        <servlet-name>appServlet</servlet-name>
        <servlet-class>pathtoAppServletClass</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
            <servlet-name>Faces Servlet</servlet-name>
            <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>

    <!-- Welcome File List -->
    <welcome-file-list>
        <welcome-file>welcome.xhtml</welcome-file>
    </welcome-file-list>
</web-app>

And navigation rule is faces-config.xml:

<navigation-rule>
        <navigation-case>
            <from-outcome>nextPage</from-outcome>
            <to-view-id>/nextPage.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>

And here is code bean invoking:

FacesContext context = FacesContext.getCurrentInstance();
      context.getApplication().getNavigationHandler().handleNavigation(context, null, "nextPage");

Thank you for your time!

  • 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-06-02T13:16:14+00:00Added an answer on June 2, 2026 at 1:16 pm

    You mean that you expect the filter to be called for nextPage.xhtml as well? JSF navigation doesn’t perform a request, forward or include. It just creates a new view within the very same request which is then to be rendered.

    If you need to create a brand new request, call ExternalContext#redirect() instead.

    externalContext.redirect(externalContext.getRequestContextPath() + "/nextPage.xhtml");
    

    Or if you’re actually inside an action method, return the navigation outcome with ?faces-redirect=true:

    public String submit() {
        // ...
    
        return "/nextPage.xhtml?faces-redirect=true";
    }
    

    Or as an alternative, depending on the concrete functional requirement, use a ViewHandler instead of a Filter so that you can hook on createView().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a servlet filter which I want to map to http://127.0.0.1:8888/ in Jetty.
I have a JSP page which display a list from servlet, it has a
I have a Filter Servlet that filters request from a Servlet. I do not
We have a servlet which occupies more virtual memory on the server due to
We have a servlet which occupies more virtual memory on the server as it
I have a servlet which takes us to an existing jsp, say home.jsp. This
I have a servlet that takes a couple of minutes to process and return
I have a Servlet called Menu that generates some html and a dynamic menu,
For many internal problems that doesn't count now, We have a Servlet filter that
I have a Error404Servlet which is configured as error-page for 404 in web.xml: <servlet>

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.