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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:44:54+00:00 2026-06-02T02:44:54+00:00

my web.xml : <context-param> <param-name>javax.faces.PROJECT_STAGE</param-name> <param-value>Development</param-value> </context-param> <welcome-file-list> <welcome-file>/secured/secure.xhtml</welcome-file> </welcome-file-list> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>

  • 0

my web.xml:

    <context-param>
            <param-name>javax.faces.PROJECT_STAGE</param-name>
            <param-value>Development</param-value>
        </context-param>

        <welcome-file-list>
            <welcome-file>/secured/secure.xhtml</welcome-file>
        </welcome-file-list>

        <servlet>
            <servlet-name>Faces Servlet</servlet-name>
            <servlet-class>javax.faces.webapp.FacesServlet</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>

        <context-param>
            <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
            <param-value>true</param-value>
        </context-param> 
    <security-constraint>
        <web-resource-collection>
          <web-resource-name>Restricted</web-resource-name>
          <url-pattern>/secured/*</url-pattern>
          <http-method>GET</http-method>
          <http-method>POST</http-method>
        </web-resource-collection>
        <auth-constraint>
          <role-name>ADMIN</role-name>
        </auth-constraint>
      </security-constraint>
<login-config>
     <auth-method>FORM</auth-method>
     <realm-name>jdbc-realm</realm-name>
     <form-login-config>
       <form-login-page>/public/login.xhtml</form-login-page>
       <form-error-page>/public/error.xhtml</form-error-page>
     </form-login-config>
   </login-config>

I want my web app to redirect unauthorized users to login page. The funny thing i had this working but i made some stupid changes and now on accessing localhost:8080 i always see secure.xhtml even when not logged in. localhost:8080/secured/secure.xhtml redirects fine.

  • 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-02T02:44:55+00:00Added an answer on June 2, 2026 at 2:44 am

    You are not using <welcome-file> entirely correctly. It should represent the sole filename of the file which needs to be served whenever a folder is been requested, irrespective of the requested folder (the root /, or /public/ or /secured/, etc).

    The welcome file is served by an internal forward as performed by RequestDispatcher#forward(). Internal forwards do not trigger the security constraints. You need to send a redirect instead.

    Change the <welcome-file> to a more sane default, e.g. index.xhtml.

    <welcome-file-list>
        <welcome-file>index.xhtml</welcome-file>
    </welcome-file-list>
    

    And create one in the webapp’s root like /index.xhtml. If you need to redirect every request on /index.xhtml to /secured/secure.xhtml, then there are basically 2 ways:

    1. Map a Filter on the URL pattern of /index.xhtml and call response.sendRedirect("secured/secure.xhtml") inside the doFilter() method. E.g.

      @WebFilter("/index.xhtml")
      public class IndexFilter implements Filter {
      
          @Override
          public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
              HttpServletResponse response = (HttpServletResponse) res;
              response.sendRedirect("secured/secure.xhtml"));
          }
      
          // ...
      }
      
    2. Put a <f:event type="preRenderView"> in the /index.xhtml which calls a backing bean method which in turn does a externalContext.redirect("secured/secure.xhtml"). E.g.

      <f:event type="preRenderView" listener="#{indexBean.redirect}" />
      

      with

      @ManagedBean
      @ApplicationScoped
      public class IndexBean {
      
          public void redirect() throws IOException {
              FacesContext.getCurrentInstance().getExternalContext().redirect("secured/secure.xhtml");
          }
      
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

web.xml <!-- JavaServer Faces --> <context-param> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>server</param-value> </context-param> <context-param> <param-name>javax.faces.CONFIG_FILES</param-name> <param-value>/WEB-INF/faces-config.xml,/WEB-INF/faces-managed-beans.xml,/WEB-INF/faces-navigation.xml</param-value> </context-param> <context-param>
Most tutorials propose a default JSF configuration similar to the following web.xml: <context-param> <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
Here is part of my web.xml: <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:application-config.xml </param-value> </context-param> application-config.xml uses
I've created very simple REST app with next web.xml: <context-param> <param-name>resteasy.scan</param-name> <param-value>true</param-value> </context-param> <listener>
I', trying to set the javax.faces.PROJECT_STAGE to production in my web.xml, but in runtime
As far as I know I can access the web.xml <context-param> s by making
in web.xml i set my welcome file to a jsp within web.xml <welcome-file>WEB-INF/index.jsp</welcome-file> inside
First, a bit of context: web.xml: I match all /app/* requests to my dispatcher:
I need the context to ApplicationContext.xml ,which I provided in web.xml as <listener> <listener-class>
I have following web-fragment.xml in a jar file, under META-INF/ It seems I cannot

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.