• Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet mapping to FacesServlet question.

 
cocoloco cocotero
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question is about the bookstore6 application in the JEE 5 tutorial
We have this piece of code in the web.xml file



And two jsp files:

index.html that has the next tag <jsp:forward page="/chooselocale.faces"/>

and chooselocale.jsp in the root directory of the web application.

How FacesServlet knows that <jsp:forward page="/chooselocale.faces"/> have to map to chooselocale.jsp if the REAL file's extension is '.jsp' and NOT '.faces'?

I imagine that by convention JSF implementation substitutes internally all '.faces' to '.jsp', isn't?

Thanks.



 
Tim Holloway
Bartender
Posts: 18412
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The web container (Tomcat, JBoss, WebSphere or whatever) digests the web.xml file when the web application is launched and sets up URL decoding and routing rules. In this particular case you have a specification that all requests with URLs ending in ".faces" are to be passed to the service method of the FacesServlet.

At that point, the FacesServlet takes over and any further URL decoding is done by it. And yes, conventionally, the URL will be dissected, and the ".faces" at the end will be replaced with a ".jsp" and the FacesServlet will use the resource with the decoded name as the View for its MVC environment.

It's been a while, but I seem to recall that you can customize how that works, but most people don't need to - even me, and I do fairly evil things routinely. So I must refer you to the FacesServlet javadocs for details.
 
cocoloco cocotero
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Tim.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!