16

This is my web.xml :

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

When I navigate to:

http://localhost:8080/LearningRoot/index.xhtml

I can see the page just fine, however when I navigate to:

http://localhost:8080/LearningRoot/

I get the error:

An Error Occurred:

The FacesServlet cannot have a url-pattern of /*. Please define a different url-pattern.

But why?

And this is my welcome file:

<welcome-file-list>
    <welcome-file>/index.xhtml</welcome-file>
</welcome-file-list>
2
  • 2
    @KeremBaydoğan did you try it in a real Java web application? Commented Mar 4, 2013 at 23:39
  • nope :) That was just a guess :) Commented Mar 5, 2013 at 8:51

1 Answer 1

23

Because that would mean Everything that ever hits that context-root will be handled by FacesServlet, a requirement that FacesServlet already knows it couldn't possibly fulfill (It obviously doesn't make sense).

To achieve the mapping you intend, use a .xhtml mapping on FaceServlet

<servlet-mapping>
  <servlet-name>Faces Servlet</servlet-name>
  <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
Sign up to request clarification or add additional context in comments.

1 Comment

@KorayTugay / will let it default to the index file per standard webapp processing. /* is an ambiguous reference

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.