Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Faces Servlet

 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All ,
I am newbie to jsf , i just want to know what is the meaning of the configuration parameter

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

and is it possible to change the extension .faces to something else like .jsp , jsf , xhtml
 
Bartender
Posts: 543
4
Netbeans IDE Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It means that every request whose request URL ends with '.faces' will be directed to the Faces Servlet, which is a java class declared as a <servlet> element in web.xml.

Sure, you can change it to something else.
 
Suresh Khant
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Dieter Quickfend for your reply ,

but i have made simple example with the configuration parameter


and the index page is index.jsp

when i tried to access the page using index.jsp i got error


and when i accessed it using index.faces it works fine

could you please explain how this happening , frankly i am still not able to understand that
 
Saloon Keeper
Posts: 24811
172
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"index.jsp" does not match your servlet filter pattern. Therefore, the request didn't get routed to the FacesServlet and the container attempted to compile index.jsp and execute it as a plain old JSP. However, since the index.jsp resource referenced JSF resources, it needed a FacesContext.

The FacesContext is created by the FacesServlet to handle the current request. Once the request has been processed, the FacesContext is destroyed. There will be no FacesContext until another request goes through the FacesServlet, at which time the cycle repeats.

It's important to understand the difference between URLs and resources. I'm using Facelets, so my View definition resources have names suffixed with ".xhtml".

Because of the filters I have set in web.xml, a "mypage.jsf" URL will be routed to the FacesServlet, which has been primed to locate resources by ripping the ".jsf" off the URL and replacing it with ".xhtml". So the "mypage.xhtml" resource will be used by the FacesServlet to render the view requested by "myfaces.jsf".
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic