background image

Extension Mapping

<< Application with a Deployment Descriptor | Application Configuration Resource File >>
<< Application with a Deployment Descriptor | Application Configuration Resource File >>

Extension Mapping

In the case of prefix mapping, there are two ways to accomplish this:
The page author can include an HTML page in the application that has the URL to the first
JSP page. This URL must include the path to FacesServlet, as shown by this tag, which uses
the mapping defined in the guessNumber application:
<a href=
"guess/greeting.jsp">
Users of the application can include the path to FacesServlet in the URL to the first page
when they enter it in their browser, as shown by this URL that accesses the guessNumber
application:
http://localhost:8080/guessNumber/guess/greeting.jsp
The second method allows users to start the application from the first JSP page, rather than start
it from an HTML page. However, the second method requires users to identify the first JSP
page. When you use the first method, users need only enter
http://localhost:8080/guessNumber
In the case of extension mapping, if a request comes to the server for a JSP page with a .faces
extension, the container will send the request to the FacesServlet instance, which will expect a
corresponding JSP page of the same name to exist containing the content. For example, if the
request URL is http://localhost/bookstore6/bookstore.faces, FacesServlet will map it
to the bookstore.jsp page.
If you are using NetBeans IDE, the time to map the FacesServlet instance is when you create
your JavaServer Faces project with NetBeans IDE:
1. In NetBeans IDE, select File
New Project.
2. In the New Project dialog, select Web from the Categories tree.
3. Select Web Application from the Projects panel.
4. Click Next.
5. Fill out the information in the Name and Location screen of the wizard.
6. Click Next.
7. Select the JavaServer Faces check box in the Framewoks screen.
8. Enter the mapping, such as *.faces, to the FacesServlet instance in the Servlet URL
Mapping field.
9. Click Finish.
After your project is open in NetBeans IDE, you can change the mapping to the FacesServlet
instance by doing the following:
1. Expand the node of your project in the Projects pane.
2. Expand the Web Pages and WEB-INF nodes that are under the project node.
Basic Requirements of a JavaServer Faces Application
The Java EE 5 Tutorial · September 2007
460