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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:41:23+00:00 2026-05-23T04:41:23+00:00

When you use JSF, you’ll have the controller servlet javax.faces.webapp.FacesServlet that will be mapped

  • 0

When you use JSF, you’ll have the controller servlet javax.faces.webapp.FacesServlet that will be mapped to the following:

<servlet-mapping>
   ...
    <url-pattern>/somefacesurl/*</url-pattern>
</servlet-mapping>

Putting a mypage.xhtml in /, we have a security risk because it will be accessed in two ways (starting from the application context):
1) /somefacesurl/mypage.xhtml
2) /mypages.xhtml

The first is processed by jsf, and is correct.
The second is not processed by jsf and so is presented to the client exposing jsf tags and this is a security risk.

I’ve found only two solutions
1) mapping always to the root url:

<servlet-mapping>
   ...
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

Good solution but permits only mappings by file extension.

2) Map to whatever url, and use security constraint to disallow access to those files as suggested in:
How to avoid user access to .xhtml page in JSF?

Both solutions are presented in the JSF 2.0 spec as viable alternatives, BUT there is no word about the different security approach of the two solutions.

Since security is NOT considered, i wonder if the first is “secure” from the point of view of access to the xhtml files or perhaps there is an hack to get the .xhtml sources.

  • 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-23T04:41:23+00:00Added an answer on May 23, 2026 at 4:41 am

    It is not true that the JSF spec mandates the first mapping. It just gives examples of the both mappings in chapter 11.1.2 of the JSF 2.0 spec (which you should be reading) and chapter 10.1.2 of the JSF 1.2 spec. Here’s an extract of relevance of the JSF 2.0 spec one (emphasis mine):

    11.1.2 Servlet Mapping

    All requests to a web application are mapped to a particular servlet based on matching a URL pattern (as defined in the
    Java Servlet Specification) against the portion of the request URL after the context path that selected this web
    application. JSF implementations must support web application that define a <servlet-mapping>
    that maps any valid url-pattern to the FacesServlet. Prefix or extension mapping may be used. When
    using prefix mapping, the following mapping is recommended, but not required:

    <servlet-mapping>
        <servlet-name> faces-servlet-name </servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    

    When using extension mapping the following mapping is recommended, but not required:

    <servlet-mapping>
        <servlet-name> faces-servlet-name </servlet-name>
        <url-pattern>*.faces</url-pattern>
    </servlet-mapping>
    

    In addition to FacesServlet, JSF implementations may support other ways to invoke the JavaServer Faces request
    processing lifecycle, but applications that rely on these mechanisms will not be portable.

    I really don’t see why an extension (suffix) mapping is “tricky”. Even more, this is my favourite JSF mapping. I recommend using *.xhtml as JSF mapping. This gives you also the advantage that you don’t need to fiddle with security constraints to prevent direct access to source files.


    Update: Please note that the source leak is not a security issue per se as long as the view is declarative and does not contain any single line of Java source code wherein variables like database username/password are stored and exposed. Since Facelets disallows for embedded raw Java code (like JSP scriptlets) I don’t see how that’s a security leak. What can a hacker do with the view source? Edit it, render it and submit back somehow? (I’d really wonder how). That’s plain impossible since JSF by default relies on the view state in the server side as well.

    I however agree with the point that the JSF specification should inform the reader more about this. I’ve created JSF spec issue 1015 for this.

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

Sidebar

Related Questions

All the tutorials I have seen seem to use *.jsf , *.faces , or
I'm trying to use CDI for my JSF/Java EE application. I have the following
I have some javascript that i'm trying to use in a jsf app. I've
Are their any good websites (characterized by high usage), that use JSF for their
I have been investigating a JSF upgrade on our existing web apps that are
On my JSF website, I've got a couple elements that I'd like to use
I want to use a temp directory that will be unique to this build.
I make a distributed embedded application that will make use of several micro-controllers. The
In our application we use jsf,we have to redirect the user to home page
How can I use ServletRequest.getLocale() in JSF application, when Servlet is absent in my

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.