Okay, I just posted a new article up on TheServerSide.com about getting started with JSF 2.0 development. However, for some reason, the new V7 content management system keeps messing up the <PRE> tags that handle Java code and XML. Yes, don't say it, because I'm already thinking it. So, I'm just going to post the XML and HTML code in the order they appear in the article right here, and reference it from that post on TSS. Also, I thought I'd link to this thread from the article so anyone who has any questions can ask away.
Who is this "Ed Burns" guy, and how can he go around saying the web.xml file is optional?
I never even entertained that idea that a web.xml file would be optional, as the whole thing does get deployed as a war file to a servlet engine. How would the servlet engine know to map a given request to the faces framework without at least mapping the FacesServlet or adding some type of listener to the web.xml file? Is there a quick link or resource that would explain this 'heretic magic' of which you speak?
By the way Ed, on my site I recommend your book as one of the two books any JSF developer needs to get if they're doing JSF development, and that's before I even suggest picking up a copy of the JSF Made Easy book I'm coming out with.
Thanks for the 'props' on the tutorial. I have a number of them in the works with the goal of helping and encouraging people to explore, adopt and get excited about working with JSF. Here's hoping it works.
Cameron Wallace McKenzie
author and cow tipper
GlassFish automatically provides a JSF servlet mapping for the /faces/*, *.faces, and *.jsf patterns, provided that any of the following conditions applies:
*Any of the classes in the web application uses a JSF 2.0 annotation
*Any initialization parameters start with javax.faces
*The WEB-INF/faces-config.xml file is present
Isn't it grand? Now you can have a JSF app without web.xml or faces-config.xml, just a bunch of .xhtml pages and Java classes annotated with @ManagedBean.
The only fly in the ointment is that, if you really want to be thoroughly modern and use web beans, erm, JSR 299 Contexts and Dependency Injection, then you should still leave something in place to trigger the servlet mapping.
Most of the talk here is that "Glassfish" automatically maps the FacesServlet. Now my question is whether this is just a sweet thing Glassfish designers decided, or whether this is just part of the Java EE specification. Since I can't seen the people at GlassFish doing this just out of the good of their heart, my assumption is that it is a Java EE requirement?
I'm currently deploying to Apache Tomcat 7, so my guess is that since Tomcat 7 is only a Servlet Engine, and not a full blow Java EE server, for Tomcat I'd still need the mapping.
Joined: Sep 11, 2006
It was an impl feature in 2.0. It is required behavior in 2.1.