Thursday, December 19, 2013


In this lesson, we will re-visit our first Hello1 JSF application (seeJAVASERVERFACES LESSON 1 – INTRODUCTION TO JSF) and discuss the role of the web.xml configuration file. When we first built our JSF application, we were concerned only about the logic that our bean will carry and the UI components that will show on our simple form. However, NetBeans created a configuration file within the WEB-INF directory that looks like this:


Inside the we define the PROJECT_STAGE that has a value of Development. This setting causes the JSF runtime to generate detailed informative error messages when common developer mistakes are detected. The choices for the project are Development, UnitTest, SystemTest and Production.

The javax.faces.webapp.FacesServlet serves as the Faces Controller servlet. All JSF pages are passed to the Faces servlet that is part of the JSF implementation code. The Faces Controller servlet is able to intercept all Faces requests, provided they have the /faces/* pattern that matches the servlet mapping’s url-pattern. The servlet-mapping element ensures that all URLs with that prefix are processed by the Faces servlet whose job is to prepare the JSF Context before routing to the requested page. The mapping rule activates the Faces servlet, which is the entry point to the JSF implementation. 

The value indicates that the container must load and initialize the servlet as soon as the application is deployed. If the value is a negative number (or missing) the container is free to load the servlet whenever it chooses.

Another important element is the which specifies the page that is loaded when the user enters the URL of the web application. Because the content of the element includes the value given in the url-pattern for the Faces Servlet, any request to the root of the application will automatically take the user to the front page of the application. 
Michail Kassapoglou