Begining With JSF

I began JSF from just yesterday. After various suggestion I have selected Netbeans for JSF. So here are some steps to begin with JSF in Netbeans. I hope it will be helpful to you. (Download Netbeans from here)

Step 1:

File > New Project

Step 2:

From the New Project dialogue box, Select Web from Category and Web Application From Rejects, then click Next button.

Step 3:

Provide the Project Name and Location for the project, then click Next button.

Step 4:

Select server, As in Netbeans, if you have GlassFish, you will get GlassFish as default. Otherwise you have to click on Add button to add Tomcat. Then click on Next button.

Step 5:

Here we select the Framework for the project, and we have to select JavaServer Faces. Then click on finish.

Step 6:

Project will get created. Press CTRL+1 to go to Project tab. Open the project list and right click on WebPages and create new JSP file with name “HelloWorld”.

Step 7:

Code in the page will looks like this.

 Document   : HelloWorld
 Created on : Jan 11, 2010, 10:43:11 AM
 Author     : prashant

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

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

Step 8:

To add JavaServer Faces components in JSP pages, you need to give your pages access to the two standard tag libraries, the HTML component tag library and the core tag library using taglib declarations. So, add these lines before <html> tag.

<%@taglib prefix="f" uri=""%>
<%@taglib prefix="h" uri=""%>

Step 9:

Add these lines to the body part.


<h:outputText lang="en_US" value="Hello World"/>


Step 10:

Press Shift+F6 to run.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: