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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:19:06+00:00 2026-06-05T21:19:06+00:00

I use Spring Security 3 and JSF2 Primefaces. Then, I create a index.xhtml for

  • 0

I use Spring Security 3 and JSF2 Primefaces. Then, I create a index.xhtml for welcome page and login.xhtml for login page

When I access the root web site, it redirect me to login.xhtml page. Why not?

How to set the welcome page to index.xhtml

This is web.xml

<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>
<welcome-file-list>
    <welcome-file>index.xhtml</welcome-file>
</welcome-file-list>

This is spring-security.xml

<global-method-security secured-annotations="enabled"
    jsr250-annotations="enabled" />

<!-- Resource Security -->
<http access-denied-page="/accessDenied.jsp">
    <intercept-url pattern="/pages/**" access="ROLE_ADMIN" />


    <form-login login-page="/login.jsf" default-target-url="/pages/index.jsf" />


    <logout logout-success-url="/login.jsf" invalidate-session="true" />
    <session-management invalid-session-url="/login.jsf">
        <concurrency-control max-sessions="10"
            error-if-maximum-exceeded="true" />
    </session-management>
</http>
  • 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-05T21:19:08+00:00Added an answer on June 5, 2026 at 9:19 pm

    For a basic application with JSF, Spring and Spring-Security, you need to configure your web.xml as follows:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"       
             xmlns="http://java.sun.com/xml/ns/javaee" 
             xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID"  
             version="3.0">
    
    <welcome-file-list>
      <welcome-file>pages/index.jsf</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>*.jsf</url-pattern>
    </servlet-mapping>
    <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/applicationContext*.xml</param-value>
    </context-param>
    <listener>
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <listener>
      <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    </listener>
    <filter>
      <filter-name>springSecurityFilterChain</filter-name>
      <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>
    <filter-mapping>
      <filter-name>springSecurityFilterChain</filter-name>
      <url-pattern>/*</url-pattern>
    </filter-mapping>
    </web-app>
    

    and also configure faces-config.xml as follows:

    <?xml version="1.0" encoding="UTF-8"?>
    <faces-config
        xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
        version="2.0">
    
         <application>
           <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
         </application>
    
     </faces-config>
    

    and your applicationContext-security.xml as follows:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans:beans xmlns="http://www.springframework.org/schema/security"
          xmlns:beans="http://www.springframework.org/schema/beans"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans.xsd
           http://www.springframework.org/schema/security
           http://www.springframework.org/schema/security/spring-security.xsd">
    
      <global-method-security secured-annotations="enabled"
    jsr250-annotations="enabled" />     
      <http auto-config="true" >
         <intercept-url pattern="/login.jsf*" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
         <intercept-url pattern="/pages/*" access="ROLE_USER,ROLE_ADMIN" />
         <intercept-url pattern="/pages/super/**" access="ROLE_ADMIN" />
         <access-denied-handler error-page="/accessDenied.jsf" />
         <form-login login-page='/login.jsf' default-target-url='/pages/index.jsf'
        always-use-default-target='true'/>
         <logout logout-success-url="/" logout-url="/j_spring_security_logout" invalidate-session="true" />
         <session-management invalid-session-url="/login.jsf">
            <concurrency-control max-sessions="10"
            error-if-maximum-exceeded="true" />
         </session-management>
     </http>
      <authentication-manager>
        <authentication-provider>
          <user-service>
            <user name="ravi" password="password" authorities="ROLE_USER, ROLE_ADMIN" />
          </user-service>
        </authentication-provider>
      </authentication-manager>
    </beans:beans>
    

    Finally, if you have any spring beans, your applicationContext.xml for annotation based configuration will be:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
         http://www.springframework.org/schema/beans/spring-beans.xsd
         http://www.springframework.org/schema/context
         http://www.springframework.org/schema/context/spring-context.xsd">
    
       <context:annotation-config/>
       <context:component-scan base-package="com.examples" />
    
     </beans>
    

    and annotate your beans like this:

    @Component 
    @Scope("request")
    

    So with all these in place along with your pages there should be no problem.

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

Sidebar

Related Questions

I use Spring Security 3 in my jsf2 web app. When a non-authenticated user
At my project I use Spring Security and GWT with url-like internationalization (http://....html?locale=en). Login
I'm developing a web application that use Spring Security for authentication of users. I
I use Spring Security 3 in my JSF2 webapp. I have a security rule
I am trying to use Spring Security 3.1 in my web app. I have
I use Spring Security and Apache proxy for a web app. When using standard
I use Spring Security 3.0.3.RELEASE. I would like to create a custom authentication processing
I am trying to use Spring Security 3.0.5 in my web application. Basically, I
I am trying to use NTLM with Spring Security. When I run my index.jsp
I have a java web application that use spring security for log in users,

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.