Quickly set up a base environment for JSF that can run under tomcat. The steps presented here are
Download jsf 1.1 Download jstl 1.0 Drop in the jar files in your web app setup the web.xml setup the faces-config.xml create a hello-world.jsp Access the page via a url My first error before getting it to work
Download jstl and standard.jar 1.0 version
You need the following jar files from that distribution
lib/jstl.jar lib/standard.jar
jsf-api.jar jsf-impl.jar jstl.jar - jstl api standard.jar - jstl implementation commons-beanutils.jar commons-collections.jar commons-digester.jar commons-logging.jar
<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>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
Please pay special attention tot he listener class. This seem to be required in tomcat.
These are available in the jsf implementation jar and will be loaded by the container automatically. No need to define them in web.xml using the taglib directive and taglib location.
Copy the following as faces-config.xml into the web-inf sub directory in line with web.xml.
<?xml version="1.0"?>
<!DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
"http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
<faces-config>
</faces-config>
<HTML>
<HEAD>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<TITLE>page title</TITLE>
</HEAD>
<f:view>
<BODY>
<P>Hello world.</P>
</BODY>
</f:view>
</HTML>
You can access this html page as
http://localhost/jsfapp/faces/some-sub-dir/hello-world.jsp
Where the "jsfapp" is your web app name and hello-world.jsp is the above jsp page. Notice the /faces/ as part of the url.
Things rarely work the first time. I have got a null pointer exception in FacesServlet.init(): 144 trying to factory up an application object. As it turns out I have forgotten the listener definition in the web.xml and then I also forgot the two jstl jar files in web-inf/lib