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 7869425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:19:01+00:00 2026-06-03T01:19:01+00:00

I have a project with this structure (I can’t change it): Web Pages META-INF

  • 0

I have a project with this structure (I can’t change it):

Web Pages
   META-INF
   WEB-INF
   assets (javascript, css and images)
   includes (top.xhtml, bottom.xhtml, etc)
   templates (master.xhtml)
   views
      fornecedor
         -home.xhtml
         -user.xhtml
         -login.xhtml
      franqueador
         -home.xhtml
         -user.xhtml
         -login.xhtml

O have a login.xhtml for each folder for a reason, I can’t change it, it was passed by the project manager.

This is my SessionFilter:

@WebFilter("/views/*")
public class SessionFilter implements Filter {

    @Override
    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) req;
        HttpServletResponse response = (HttpServletResponse) res;
        HttpSession session = request.getSession(false);
        LoginController loginController = (LoginController) ((boolean) (session != null) ? session.getAttribute("loginController") : null);
        if (!request.getRequestURI().endsWith("/fornecedor/index.xhtml")) {
            if (loginController == null || !loginController.getIsLoggedIn()) {
                response.sendRedirect(request.getContextPath()
                        + "/views/index.xhtml");
            } else {
                chain.doFilter(req, res);
            }
        }
    }


}

And it doesn’t work, returns a blank page with no html code and when I change the .xhtml to .html, it gives me a redirect loop.

I need to avoid all my login.xhtml pages and the index.xhtml on views folder. I have debugged the if on my filter but it always returns false.

EDIT

Following BalusC answer I came to this:

if (!request.getRequestURI().endsWith("/views/index.html")
                && !request.getRequestURI().endsWith("/views/fornecedor/login.html")
                && !request.getRequestURI().endsWith("/views/franqueado/login.html")
                && (loginController == null || !loginController.getIsLoggedIn())) {
            response.sendRedirect(request.getContextPath() + "/views/index.html");

        } else {
            chain.doFilter(req, res);
        }

It is working but there is another problem, if I have 10 folder, I’ll need to add them on this if statement…I need to make it automatic.

  • 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-03T01:19:03+00:00Added an answer on June 3, 2026 at 1:19 am

    Your first if condition has no else. That explains the blank page.

    You need to evaluate the URL and logged-in conditions in a single if instead.

    if (!request.getRequestURI().endsWith("/fornecedor/index.xhtml") && (loginController == null || !loginController.getIsLoggedIn()) {
        response.sendRedirect(request.getContextPath() + "/views/index.xhtml");
    } else {
        chain.doFilter(req, res);
    }
    

    As to the redirect loop, that’s because your FacesServlet is mapped on an URL pattern of *.html instead of *.xhtml for some unclear reason. So the request URL does never match. Fix the URLs in the filter accordingly. To generalize it for all login.html and index.html requests, just do as follows:

    if (!request.getRequestURI().endsWith("/index.html") 
        && !request.getRequestURI().endsWith("/login.html") 
        && (loginController == null || !loginController.getIsLoggedIn())
    {
        response.sendRedirect(request.getContextPath() + "/views/index.html");
    } else {
        chain.doFilter(req, res);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have this project structure Foo.Data reference EntityFramework Foo.Business reference Foo.Data Foo.Web reference
Okay so, I have this project structure: package A.B class SuperClass (this class is
I have a python project with this directory structure and these files: /home/project_root |---__init__.py
I have a project with a structure like this: project code art config Art
In an ASP.NET MVC3 project I have a structure like this: Core.csproj -> 3rdparty1.dll
I have a project created in Eclipse that has roughly this structure: src conf
I have the following project structure which I can't get to work: Mac OS
I have a project which has a calling structure similar to this: main project/application
I have this project that it's due in a few hours and I still
So I have this project in PHP where I have some include files next

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.