Home arrow Java & J2EE arrow Page 7 - Introduction to JavaServer Faces, Part 1

Creating the Directory Structure - Java

This chapter gently introduces the JavaServer Faces technology. More importantly, it teaches you how to write your first JSF application to get a feel for how this great technology works.  In addition to the sample chapters, this chapter prepares you for the next chapters by introducing the JSF Application Programming Interface (API) and the Application Configuration file. This excerpt comes from chapter two of JavaServer Faces Programming, by Budi Kurniawan (McGraw-Hill/Osborne, ISBN 0-07-222983-7, 2004).

  1. Introduction to JavaServer Faces, Part 1
  2. Understanding the Request Processing Lifecycle Phases
  3. Using an Application Configuration File
  4. Writing a JSF Application
  5. Writing JavaBeans and Event Listeners
  6. Creating the Event Listener and Component Tree Example
  7. Creating the Directory Structure
  8. Writing the Object Model for the Listener and Component Tree Example
  9. Defining Taglib Directives
By: McGraw-Hill/Osborne
Rating: starstarstarstarstar / 74
March 08, 2004

print this article



As the first step, you need to create a directory structure for your JSF application. In Tomcat, you create this under webapps. The directory structure for your application, called JSFCh02a, is depicted in Figure 4. The directory contains all the required components that you will build in this example.

First, note that you must copy the .jar files containing the JSF implementation into the WEB-INF/lib directory. Then, in the WEB-INF/classes directory, you have the JavaBean class. In the WEB-INF directory, you have the deployment descriptor (web.xml) and the application configuration file (faces-config.xml). Lastly, the adder.jsp page is in the application directory itself.

Writing the Deployment Descriptor for the Listener and Component Tree Example

Just like any other servlet/JSP application, this JSF application needs a deployment descriptor. Listing 1 presents the deployment descriptor for this application.

JSF structure

Figure 4 The directory structure of the listener and
component tree example

Listing 1 The Deployment Descriptor (web.xml)

<?xml version="1.0"? >
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

<P align=left
P align=left><web-app>
<!-- Faces Servlet -->
<servlet-name>Faces Servlet</servlet-name>

<P align=left
P align=left>  <!-- Faces Servlet Mapping -->
<servlet-name>Faces Servlet</servlet-name>

There are two sections in the deployment descriptor. The servlet element registers the FacesServlet, and the servlet-mapping element states that any request containing the pattern /faces/ in the URL must be passed to the FacesServlet

Buy this book now!Remember: This is part one of the second chapter of JavaServer Faces Programming, by Budi Kurniawan (McGraw-Hill/Osborne, ISBN 0-07-222983). Stay tuned for part 2 of "Introduction to JavaServer Faces," where we learn about JSP, JavaBeans, and Model 2. 
Buy this book!

>>> More Java & J2EE Articles          >>> More By McGraw-Hill/Osborne

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- More Java Bugs Lead to More Attacks
- Oracle's Java One Brings News, Surprises
- Oracle Patches Java Runtime Environment
- Apple Syncs Java Update with Oracle
- Spring 3.1 Java Development Framework Compat...
- Jelastic Java PaaS Availability and Pricing ...
- NetBeans 7.1 Released, Supports JavaFX 2
- SolarWinds Releases Newest Version of Java M...
- Free Monitoring Tool for Java Apps on Heroku
- Heroku Adds JCloud Platform Support, Java 7 ...
- Java SE 8 Speculation in Full Swing
- Java SE 7 Now Available
- New JVM Language and Java Reporting Tool
- Java 7 Release Update and New Eclipse Toolkit
- The Best Java Netbeans IDE Plugins

Developer Shed Affiliates


Dev Shed Tutorial Topics: