Enable JSF in Tomcat

by Vinoth 2009-04-20 16:37:30

The Following Steps are used to Configure java server faces in Tomcat

Installation:

1. Download the latest version of the JSF Reference Implementation from
http://java.sun.com/j2ee/javaserverfaces/download.html
2. Unzip the file and it contains a subdirectory named something like jsf-1_1_01.
3. Copy all JAR files files from the lib subdirectory of your JSF installation (such as c:jsf-1_1_01lib) to the common/lib subdirectory of Tomcat
* commons-beanutils.jar
* commons-collections.jar
* commons-digester.jar
* commons-logging.jar
4. Copy the following two JAR files from the webapps/jsp-examples/WEB-INF/lib subdirectory of your Tomcat installation to the common/lib subdirectory of Tomcat.
* jstl.jar
* standard.jar

Configuration:

1. Create a subdirectory with the name of your web application (such as myproject) inside the webapps directory of your Tomcat directory (such as c:jakarta-tomcat-5.5.7webappsmyproject)
2. Inside that subdirectory, create the following directory structure:
myproject
WEB-INF
classes
mypackage

3. Place your files as follows:

* index.jsp and other web pages into app
* faces-config.xml and web.xml into app/WEB-INF
3.1:
Configure faces-config.xml

< ?xml version="1.0" encoding="UTF-8"? >
< !DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
"http://java.sun.com/dtd/web-facesconfig_1_1.dtd" >
< faces-config xmlns="http://java.sun.com/JSF/Configuration" >
< !-- Default render kit for ADF components -->
....
< application >
< default-render-kit-id > hiox.app.core < /default-render-kit-id >
< /application >
...
< /faces-config >


3.2: Configure web.xml file:

< ?xml version="1.0"? >

< !DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >

< web-app >
<servlet>
< servlet-name > Faces Servlet < /servlet-name >
< servlet-class > javax.faces.webapp.FacesServlet < /servlet-class >
< load-on-startup > 1 < /load-on-startup >
< /servlet >

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

4. Source code for your beans into myproject/WEB-INF/classes/mypackage (where mypackage should be the package name that you use for your classes, such as bigjava).

Tagged in:

2283
like
0
dislike
0
mail
flag

You must LOGIN to add comments