JSF HelloWorld

In this article you will learn, how to write a Simple Hello World Application using JSF.

First create a new Dynamic Web Project and configure it as Maven Project. For Reference, Click Here

1. JSF 2.0 Dependencies

Add the following dependencies in pom.xml


2. Deployment Descriptor

Write the following code in web.xml to configure JSF

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

3. JSP Page

Create a jsp file helloworld.jsp and write the following code.

<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Hello World!!!</title>
        <h1><h:outputText value="Hello World!!!" /></h1>

4. Run Project
When you run the project, following screen will be displayed as shown in Figure 1.1

Figure 1.1 Figure 1.1

The folder structure of the example is shown below in Figure 1.2

Figure 1.2 Figure 1.2

You can download the source code of this example here.

No comments yet.

Leave a Reply