Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training

JSF Installation on Tomcat

Complete Java Server Faces (JSF) Tutorial - JSF Tutorials. JSF Tutorials at Rose India covers everything you need to know about JSF.


JSF Installation on Tomcat


Complete Java Server Faces (JSF) Tutorial - JSF Tutorials. JSF Tutorials at Rose India covers everything you need to know about JSF.

In this tutorial we will explain you how to install  JSF 1.2 on tomcat server. We will develop small web application to test our integrated environment.

As stated in the last section, JSF 1.2 requires servler 2.5 and jsp 2.1 complaint container. So, to install and test JSF 1.2 we will use Tomcat 6.0 which is JSF 1.2 complaint container. We will download Tomcat 6.0, JSTL, and JSF 1.2, and then explain you the steps involved in integrating these stuffs.

Download JSF

The reference implementation of JSF 1.2 can be download from from . For this tutorial we have downloaded Save the downloaded file into any directory of your choice and then unzip it.

Download Tomcat

The latest version of tomcat can be downloaded from We have downloaded tomcat for developing and testing the application. Unzip the downloaded file and then copy the "apache-tomcat-6.0.13" folder to directory from where you want to run the server. Here I am assuming that you have latest version of JDK ( JDK 5 or higher) and you are to use it from command prompt. To test Tomcat 6.0, go to the server directory "apache-tomcat-6.0.13/bin" and then double click on the startup.bat file. Then open the browser and type http://localhost:8080, your browser should display the tomcat server home page.

Downloading JSL Library

You can download the latest version of JSTL from For this tutorial we have downloaded

Creating blank web application

Now we are ready to create our integrated application. Please follow the follow steps:

  1. Creating Web application
    Create a directory "jsf12" under "apache-tomcat-6.0.13\webapps".
  2. Create WEB-INF directory under "apache-tomcat-6.0.13\webapps\jsf12".
  3. Create classes and lib directories under "apache-tomcat-6.0.13\webapps\jsf12\WEB-INF".
  4. Create file web.xml under "apache-tomcat-6.0.13\webapps\jsf12\WEB-INF" with the following content:
    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE web-app PUBLIC
    "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"


    <!-- Faces Servlet -->
    <servlet-name>Faces Servlet</servlet-name>
    <load-on-startup> 1 </load-on-startup>

    <!-- Faces Servlet Mapping -->
    <servlet-name>Faces Servlet</servlet-name>

    In the above file we have defined the "Faces Servlet" and then mapped all the requests "*.jsf" to it.
  5. Create file faces-config.xml under "apache-tomcat-6.0.13\webapps\jsf12\WEB-INF" with the following content:
    <?xml version='1.0' encoding='UTF-8'?>

    <!DOCTYPE faces-config PUBLIC
    "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"



    In the next sections we will learn how to use faces-config.xml.

  6. Copying JSF 1.2 library: Copy jsf-api.jar and jsf-impl.jar from "jsf-1.2_04-b10-p01\jsf-1.2_04-b10-p01\lib" into  "apache-tomcat-6.0.13\webapps\jsf12\WEB-INF\lib" directory.

  7. Copying JSTL library: Copy standard.jar and jstl.jar from "\jakarta-taglibs-20060824\jakarta-taglibs\standard-1.0\lib" into  "apache-tomcat-6.0.13\webapps\jsf12\WEB-INF\lib" directory.
  8. Creating JSP files:
    Create index.jsp file into "apache-tomcat-6.0.13\webapps\jsf12\" directory and paste the following content in the file:
    <jsp:forward page="hello.jsf"/>

    index.jsp file simply forwards the request to hello.jsf.

    create hello.jsf in the same directory within following content:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <[email protected] uri="" prefix="h"%>
    <[email protected] uri="" prefix="f"%>
    <h:outputText value="Hello, Welcome to JSF 1.2 World!"/>

    The tag <h:outputText value="Hello, Welcome to JSF 1.2 World!"/> generates "Hello, Welcome to JSF 1.2 World!" on the browser. In the next section we will learn these tags in detail.

    Now we have completed the integration steps and ready to test the application.

Testing the application

To test application run tomcat and then type http://localhost:8080/jsf12/ in the browser. You browser should display "Hello, Welcome to JSF 1.2 World!" message. Here is the screen shot of the output:

Congratulations you have successfully installed JSF 1.2 on tomcat 6.0 server.

Download the integrated application from here.


Share on Google+Share on Google+

JSF Installation on Tomcat

Posted on: February 26, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: JSF Installation on Tomcat   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
Kalle Anka
September 23, 2011
hello.jsf should be hello.jsp

I got an error saying tomcat couldnt find hello.jsp. Solutions> Just change the filename for hello.jsf to hello.jsp. This may sound strange but this is how jsf works per default and it is a consequence of implementing jsf on top on the servlet technology. The .jsf is mapped to the file extension .jsp. I got this information from the book Core JavaServer Faces, second edition on page 13.
November 3, 2011
Now working

Tried all the above mentioned steps, but at the end result that I am getting is HTTP Status 404 - /JSFwebApp/hello.jsp ------------------------------------------------------------ type Status report message /JSFwebApp/hello.jsp description The requested resource (/JSFwebApp/hello.jsp) is not available. It seems like instead of jsf page is redirecting to jsp.
Unknown Stranger
November 24, 2011
Change the name of the file to hello.jsp

Change the name of the file to hello.jsp instead of hello.jsf
April 19, 2012
Code Error

the hello file should be a jsp not a jsf. The download has the file named properly but both index.jsp files call hello.jsf which will not work.
Ognyan Zhelezov
May 17, 2012

Great, this is very usefull example. I have downloaded .zip file from the last link an put it in Tomcat's webapps directory. It works!
June 23, 2012

your application is not working in apache tom cat 4.0....
July 9, 2012
tom cat