JSF Hello World

In this example, we will be developing JSF Hello World example application in NetBeans IDE.

JSF Hello World


In this example, we will be developing JSF Hello World example application in NetBeans IDE. This example illustrates how to print hello world in JSF application using NetBeans IDE. NetBeans IDE provides simple way to create and test web applications. Its provides standardized directory structure to create the project artifacts such as jsp pages, xml pages, java classes etc.

Steps to create JSF Hello World Example:

1. Go to your project and right click on "Web Pages" folder.
2. The select "New" option and  and click on "JSP..." as shown below.

Creating new JSP page in NetBeans IDE

Now it will open a jsp page where you can write your code. For this example, we will use code given in HelloWorld.jsp as below.

Source code of HelloWorld.jsp


  Document : HelloWorld
  Created on : Sep 9, 2008, 8:03:01 PM
  Author : sandeep

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>

  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JSP Page</title>
  <h1><h:outputText value="Hello World!" /></h1>

Now you need to run the application to see the output for the code written above. The following steps can be used to run the JSF application in NetBeans IDE.

  • Right click on the HelloWorld.jsp page.
  • Select Run File from the appeared menu.
  • The Run File will start the server deploy the application and display the output on the web browser.

OR, Run the above file by using Shift + f6 keys on keyboard. The output is shown on the browser like below:

Download Source Code

Share on Google+Share on Google+

JSF Hello World

Posted on: June 10, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: JSF Hello World  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
Nidhi Gupta
July 2, 2012

package nidhi; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.GenericServlet; import javax.servlet.ServletException; public class NewSyll extends GenericServlet { public void service(ServletRequest req, ServletResponse res)throws ServletException, IOException { res.setContentType("text/html"); PrintWriter pw=res.getWriter(); pw.println("<B>Hello World!</B>"); pw.close(); } @@@@@@@@@@ I am getting several errors when tried this program in NetBeans....plz help me in rectifying the errors