This blog shows you how to write a simple JavaServer Faces Application with Eclipse and GlassFish server. For a complete JSF application with JPA application, please visit the links at the end of this blog
1. Requirements:
-CoBundled (Eclipse 3.4.1 & GlassFish Servers) or
-Install Eclipse 3.4.1 and GlassFish plugin
2. Configuration
-Set Web editor for JSP page default editor
From Window menu, select Preferences > General > Editors > File Associations
In the File types section, select *.jsp
In the Associated editors section, select Web Page Editor > Select the Default button

-Register JSTL library
Select Windows->Preferences->Web->JavaServer FacesTools-> Libraries.
Click on the New.. button to add a new library
Create the JSF Libraries (name JSTL)
(Note: you should be able to find jstl-impl.jar files under ..\glassfishv3-prelude\glassfish\modues\web directory)

3. Create the JSF Project
From File > New > select to create a New Dynamic Web Application names it as MyJSF.
Set target runtime to GlassFish V3 Prelude (you can also select GlassFish V2.1)
Set Configuration to JavaServer Faces v1.2 Project > click Next button

On JSFCapabilities panel, select radio button Server Supplied JSF Implementation. Add JSTL library

-Add a JSP page to JSF project
Right-click at myJSF project, select New > JSP to create a page called hello.jsp. In the Select Templates page, select the New Java Server Face (JSF) Page (html) template. Click Finish. The page will be
opened in the Web Page Editor as shown below

-To turn ON the palette to design the Canvas components
From the Window menu, select Show View > Others > expand General > then select Palette > click Ok. The palette can appears at the IDE button but you can drag it to the top right as shown in the below figure

-Add a command button to the canvas
Open the Properties View. Right-mouse click on the designer canvas and from thecontext menu, select Show->Properties
In the Palette View, click on the section JSF HTML to display
the list of components
Drag-and-drop the CommandButton to the canvas "drag and drop section"
In the properties view, click on Quick Edit
Set the Value attribute to ClickMe and the Action attribute to "#{myBean.action}"
(Note: later you will write MyBean.java to process the actions your declare in hello.jsp file)

-Add a PanelGrid
Drop the Panel Grid before the Command Button, but inside the Form tag, panel Grid is created with a predefined set of OutputText components
At the end it should looks like the figure below (you can cut and paste the statement below to your hello.jsp file)
<h:form>
<h:outputLabel for="input" value="Enter your name:"/>
<h:inputText id="input" value="#{myBean.input}" required="true"/>
<h:commandButton value="ClickMe" action="#{myBean.action}"/>
</h:form>
<h:outputText value="#{myBean.output}"/>
-Create MyBean bean
In the Project Explorer, expand the node, MyJSF->WebContent. Double-click
on faces-config.xml . This will launch the FacesConfiguration editor.

-Select the ManagedBean tab. 
Click on the Add button. This will launch the New Managed Bean wizard.
Select the option, Create a new Java class. In the next wizard panel,
enter the package as, j2eetest and the Name ofthe class as MyBean . Click the Finish button.


-Edit the Java class, j2eetest.MyBean. Add thefollowing code and save
private String input;
private String output;
Right-click at the MyBean.java > select Sources menu >Generate Setter&Getter.
At the end you should have the MyBean.java code look like this
Now you're ready to run your JSF Hello.jsp file.
Right-click at hello.jsp file > select Run As > Run on Server
![]()
-Choose GlassFish V3 Prelude
Enter your name at the text field > click ClickMe button.
-For building a JSF application with JPA, please visit the links below:
-Using Oracle link
-Using DAO




