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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:06:23+00:00 2026-05-20T22:06:23+00:00

Currently i updating a jsf project and a realize a strange thing about project

  • 0

Currently i updating a jsf project and a realize a strange thing about project when a jsf page get a request and page returned to client i see page completely in browser after this a new request to same page arrives despite the fact i didnt click any thing i am using navigation handler for navigation.I am using jsf(myfaces),richfaces in my project.

i set two break points on these class and i see most of the pages ,not all ,sent request and request goes through menufilter -> myfacesservletwrapper (at that point browser shows page completly)after this menufilter break a nother request for same page .

package com.endersys.itap.ui;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.endersys.itap.ui.module.user.User;
import com.endersys.itap.ui.module.user.UserManager;
import java.io.FileInputStream;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;


public class MenuFilter implements Filter {

    private String ALLOWED = "login.xhtml";
    private String ALLOWED_FOLDER = "a4j";


    private static boolean searchEnabled = false;
    private static boolean syslogServiceEnabled = false;
    private static String SYSLOG_PAGE= "syslogsettings.xhtml";
    private Properties conf;
    private String SEARCH_PAGE= "search.xhtml";

    private static final String BASE_PATH = "/opt/itap/logmonitor/";
    private static final String CONF_PATH = BASE_PATH + "etc/logmonitor.properties";

    private static Logger logger = Logger.getLogger(MenuFilter.class.getName());

    public void destroy() {
    }

     public void init(FilterConfig arg0) throws ServletException {
        if(loadConfiguration())
        {
            if(conf.getProperty("search_enabled").equalsIgnoreCase("true"))
            {
                searchEnabled = true;
            }

            try
            {
                if(conf.getProperty("syslog_enabled").equalsIgnoreCase("true"))
                {
                    syslogServiceEnabled = true;
                }
            }catch(Exception exc)
            {
                exc.printStackTrace();
            }
        }
    }

    private boolean loadConfiguration()
    {
        conf = new Properties();
        FileInputStream fis = null;
        try {
            fis = new FileInputStream(CONF_PATH);
            conf.load(fis);
        } catch (Exception e) {
            logger.log(Level.SEVERE, e.getMessage(), e);
            return false;
        } finally {
            try {
                if (fis != null) {
                    fis.close();
                }
            } catch (IOException e) {
                logger.log(Level.SEVERE, e.getMessage(), e);
            }
        }
        return true;
    }

     /**
     * TODO Unit test this function extensively.
     */
    public void doFilter(ServletRequest req, ServletResponse res,
            FilterChain chain) throws IOException, ServletException {
        try
        {
            UserManager userManager = (UserManager) ((HttpServletRequest) req)
                    .getSession(true).getAttribute("userManager");

            // http://localhost:8080/itapgui-v2*/index.xhtml*
            String relativePath = ((HttpServletRequest) req).getServletPath();
            // Servlet path has a leading "/" but our menu items do not.
            relativePath = relativePath.substring(1);

            // http://localhost:8080*/itapgui-v2*/index.xhtml
            String contextPath = ((HttpServletRequest) req).getContextPath();

            if(!searchEnabled && relativePath.endsWith(SEARCH_PAGE))
            {
                ((HttpServletResponse) res).sendRedirect(contextPath
                            + "/index.xhtml");
                return;
            }

            if(!syslogServiceEnabled && relativePath.endsWith(SYSLOG_PAGE))
            {
                ((HttpServletResponse) res).sendRedirect(contextPath
                            + "/index.xhtml");
                return;
            }

            if (!relativePath.endsWith(ALLOWED)
                    && !relativePath.startsWith(ALLOWED_FOLDER)) {
                // Permission required.
                // if (relativePath.endsWith("logout.xhtml")) {
                // ((HttpServletRequest) req).getSession(true).invalidate();
                // ((HttpServletResponse) res).sendRedirect(contextPath
                // + "/login.xhtml");
                // return; // Required.
                // }

                if (userManager == null) {
                    // Not authorized.
                    if(relativePath != null && relativePath.endsWith("index.xhtml"))
                    {
                         ((HttpServletResponse) res).sendRedirect(contextPath
                            + "/login.xhtml");
                    }else
                    {
                    ((HttpServletResponse) res).sendRedirect(contextPath
                            + "/login.xhtml?session=expired");
                    }
                    return; // Required.
                }
                User user = userManager.getUser();
                if (user.getId() == null) {
                    // Not authorized.
                    ((HttpServletResponse) res).sendRedirect(contextPath
                            + "/login.xhtml");
                    return; // Required.
                } else if (user.getId() != 1) {
                    Menu menu = (Menu) ((HttpServletRequest) req).getSession(true)
                            .getAttribute("menu");
                    MenuItem item = menu.getItemByPath(relativePath);
                    if(item != null)
                    {
                        if (!userManager.access(item.getPerms())) {
                            ((HttpServletResponse) res).sendRedirect(contextPath
                                    + "/error.xhtml");
                            return; // Required.
                        }
                    }
                }
            }
            chain.doFilter((HttpServletRequest) req, (HttpServletResponse) res);

        }catch(Exception exc)
        {
            exc.printStackTrace();

            if(exc instanceof IOException)
            {
                throw (IOException) exc;
            }
            else if(exc instanceof ServletException)
            {
                throw (ServletException) exc;
            }

        }
    }



}





public class MyFacesServletWrapper extends MyFacesServlet {

    private static final String CONN_ERROR_URI = "/dberror.xhtml";
    private static final String OTHER_ERROR_URI = "/errors.xhtml";

    @Override
    public void service(ServletRequest request, ServletResponse response) throws IOException, ServletException {
        try {
            super.service(request, response);

        } catch (ServletException e) {
            HttpServletRequest req = (HttpServletRequest) request;
            HttpServletResponse res = (HttpServletResponse) response;

            //if an database exception has occured
            if (ExceptionUtils.indexOfType(e, javax.persistence.PersistenceException.class) != -1) {
                res.sendRedirect(req.getContextPath() + CONN_ERROR_URI);
            }
            else {
                // add the exception to the session scope attribute
                // to show stack trace
                req.getSession().setAttribute("exception", e);
                res.sendRedirect(req.getContextPath() + OTHER_ERROR_URI);
            }
        }
    }

}
  • 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-20T22:06:23+00:00Added an answer on May 20, 2026 at 10:06 pm

    Based on the conversation in the comments I would suggest you look into the details of the JSF lifecycle. Keep in mind that any reRendering or ajaxRendred="true" might kick off the lifecycle. This site has been very helpful for me in the past: http://www.ibm.com/developerworks/library/j-jsf2/

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

Sidebar

Related Questions

I'm currently updating our software installer and have a few questions about getting the
When I do a git push, I see the following: warning: updating the currently
My page is currently updating an existing xml, the problem is that when it
We are currently working on a small project, we are updating and adding some
I'm currently toying with updating page content via the following: <%= link_to(content_tag(:span, 'Settings'), edit_admin_store_path,
I'm currently updating a client application that makes use of a WCF web service
I currently am tasked with updating an XML file (persistance.xml) within a jar at
I'm currently in the process of updating a site from preview 2 of ASP.NET
We’re currently in the process of updating the email dispatch part of our application
I've currently run into a performance problem when updating properties on lots of dom

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.