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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:11:35+00:00 2026-05-29T05:11:35+00:00

I searched for a solution but could not find an answer for my specific

  • 0

I searched for a solution but could not find an answer for my specific issue. I have a login.xhtml page but the JSF tags are not rendered. When I successfully log in, the tags are renderen correctly. so somehow the login.xhtml does not pass through the faces servlet. This seems strange because all is configured correctly. How can I force the login.xhtml to be rendered correctly?

Here is my web.xml portion

<login-config>
    <auth-method>FORM</auth-method>
    <realm-name>file</realm-name>
    <form-login-config>
        <form-login-page>/login.xhtml</form-login-page>
        <form-error-page>/error.xhtml</form-error-page>
    </form-login-config>
</login-config>

<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
</servlet-mapping>

Login.xhtml

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
template="/WEB-INF/templates/eps_template.xhtml">
<ui:define name="body">

    <h2>Hello, please log in:</h2>
    <form name="loginForm" method="post" action="j_security_check">
        <p>
            <strong><label for="username">Please type your user
                    name: </label> </strong> <input id="username" type="text" name="j_username"
                size="25" />
        </p>
        <p>
            <strong><label for="password">Please type your
                    password: </label> </strong> <input id="password" type="password" size="15"
                name="j_password" />
        </p>
        <p>
            <input type="submit" value="Submit" /> <input type="reset"
                value="Reset" />
        </p>
    </form>

</ui:define>
</ui:composition>

So the html form is shown correctly, but the template components are not. The output is:

<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
template="/WEB-INF/templates/eps_template.xhtml">
<ui:define name="body">

    <h2>Hello, please log in:</h2>
    <form name="loginForm" method="post" action="j_security_check">
        <p>
            <strong><label for="username">Please type your user
                    name: </label> </strong> <input id="username" type="text" name="j_username"
                size="25" />

        </p>
        <p>
            <strong><label for="password">Please type your
                    password: </label> </strong> <input id="password" type="password" size="15"
                name="j_password" />
        </p>
        <p>
            <input type="submit" value="Submit" /> <input type="reset"
                value="Reset" />
        </p>

    </form>

</ui:define>
</ui:composition>

Update 31 January 2012

Configuration:
Glassfish 3.1
Primefaces 3.1
JSF 2.1

I have a index.html page which forwards to home.jsf. But the container notices the user is not logged in so it redirects to login.xhtml.

If I add only the *.jsf to the web.xml, all is working fine but the login.jsf does not render JSF tags.

<url-pattern>*.jsf</url-pattern>
<url-pattern>*.xhtml</url-pattern>

If I also add *.xhtml the login.jsf page does render tags but not properly according to the Primefaces skin. When I click submit the jquery.js is printed to the screen.

Here is the complete web.xml

<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>
    <url-pattern>*.xhtml</url-pattern>
    <url-pattern>*.html</url-pattern>
</servlet-mapping>
<context-param>
    <param-name>facelets.DEVELOPMENT</param-name>
    <param-value>true</param-value>
</context-param>

<!-- Primefaces -->
<servlet>
    <servlet-name>Resource Servlet</servlet-name>
    <servlet-class>org.primefaces.resource.ResourceServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>Resource Servlet</servlet-name>
    <url-pattern>/primefaces_resource/*</url-pattern>
</servlet-mapping>

<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Production</param-value>
</context-param>
<context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>server</param-value>
</context-param>
<context-param>
    <param-name>primefaces.THEME</param-name>
    <param-value>bluesky</param-value>
</context-param>
<filter>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
    <init-param>
        <param-name>thresholdSize</param-name>
        <param-value>5120</param-value>
    </init-param>
    <init-param>
        <param-name>uploadDirectory</param-name>
        <param-value>/****</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
</filter-mapping>


<!-- security -->

<login-config>
    <auth-method>FORM</auth-method>
    <realm-name>file</realm-name>
    <form-login-config>
        <form-login-page>/login.xhtml</form-login-page>
        <form-error-page>/error.xhtml</form-error-page>
    </form-login-config>
</login-config>

<security-role>
    <role-name>epsadmin</role-name>
</security-role>
<security-constraint>
    <web-resource-collection>
        <web-resource-name>Admin</web-resource-name>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>admin</role-name>
    </auth-constraint>
</security-constraint>

<security-constraint>
    <display-name>Restrict raw XHTML documents</display-name>
    <web-resource-collection>
        <web-resource-name>XHTML</web-resource-name>
        <url-pattern>*.xhtml</url-pattern>
    </web-resource-collection>
    <auth-constraint />
</security-constraint>

Update after answer 2 by BalusC. This is now the complete web.xml

<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>facelets.DEVELOPMENT</param-name>
    <param-value>true</param-value>
</context-param>

<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Production</param-value>
</context-param>
<context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>server</param-value>
</context-param>
<context-param>
    <param-name>primefaces.THEME</param-name>
    <param-value>bluesky</param-value>
</context-param>
<filter>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
    <init-param>
        <param-name>thresholdSize</param-name>
        <param-value>5120</param-value>
    </init-param>
    <init-param>
        <param-name>uploadDirectory</param-name>
        <param-value>/tempupload</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
</filter-mapping>


<welcome-file-list>
    <welcome-file>home.jsf</welcome-file>
</welcome-file-list>


<login-config>
    <auth-method>FORM</auth-method>
    <realm-name>file</realm-name>
    <form-login-config>
        <form-login-page>/login.jsf</form-login-page>
        <form-error-page>/error.jsf</form-error-page>
    </form-login-config>
</login-config>

<security-role>
    <role-name>admin</role-name>
</security-role>
<security-constraint>
    <web-resource-collection>
        <web-resource-name>Admin</web-resource-name>
        <url-pattern>*.jsf</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>admin</role-name>
    </auth-constraint>
</security-constraint>

<error-page>
    <error-code>403</error-code>
    <location>/errorpages/error403.jsf</location>
</error-page>
<error-page>
    <error-code>404</error-code>
    <location>/errorpages/error404.jsf</location>
</error-page>
<error-page>
    <error-code>500</error-code>
    <location>/errorpages/error500.jsf</location>
</error-page>
<error-page>
    <exception-type>com.*******.ApplicationException</exception-type>
    <location>/errorpages/error500.jsf</location>
</error-page>

This is the url I get when pressing the submit button

csman/javax.faces.resource/primefaces.js.jsf?ln=primefaces&v=3.1-SNAPSHOT

This is the output.

PrimeFaces={escapeClientId:function(a){return"#"+a ..........etc

However, when I press connect to the start URL again, I am successfully directed to the home.jsf page. So the login procedure went OK.

Not that the login.jsf page displays JSF tags but they are not skinned.

Weird?!

  • 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-29T05:11:35+00:00Added an answer on May 29, 2026 at 5:11 am

    You have configured your FacesServlet to listen on *.jsf URLs. So all you need to do is to change the login and error pages to point to exactly that URL.

    So, change

    <form-login-page>/login.xhtml</form-login-page>
    <form-error-page>/error.xhtml</form-error-page>
    

    to

    <form-login-page>/login.jsf</form-login-page>
    <form-error-page>/error.jsf</form-error-page>
    

    Don’t forget to remove the additional *.xhtml URL pattern on the FacesServlet as suggested by the other answer. You have a <security-constraint> on *.xhtml to block the endusers seeing the raw source and this won’t work well together. So your FacesServlet mapping should have only this:

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>
    

    As a different alternative, replace the mapping on *.jsf by *.xhtml

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>
    

    and stick to using *.xhtml in all URLs/links throughout your website and remove the <security-constraint> on *.xhtml. With a mapping on *.xhtml the endusers will never see the raw source anyway. Every single XHTML file will be passed through the FacesServlet.


    Unrelated to the concrete problem, as per your comment on the other question you seem to have a meta refresh on the index page. This makes little sense. Just add <welcome-file>home.xhtml</welcome-file> to the <welcome-file-list>. This works fine if you’ve mapped FacesServlet on *.xhtml.

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

Sidebar

Related Questions

I have searched around a lot for a solution, but could not find any.
I searched all over, but could not find a solution. I have a view
I searched the site but I could not find any solution to this problem.
I've searched high and low, but I could not find a solution, to what
I've searched all over the net, but I could not find a solution to
i have searched a lot but could not find the exact way to do
I searched everywhere but could not find a solution to this. I am trying
I have searched online for a solution, but have yet to find one that
I searched, but surprisingly couldn't find an answer. I have a long NSString that
I have searched all around to find a solution to my problem, but i

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.