JSF/GlassFish Architecture

The standard web application architecture is shown to the left. The web application often consists of a general purpose application server, with a framework layer above it that provides better separation between different aspects of of applications.

GlassFish is a Java-based application server. JSF is a popular framework that can run on top of GlassFish and other Java-based application servers.

JSF/GlassFish Applications


JSF and GlassFish have features supporting the following aspects of a web application:

  • Presentation — the output from the application
  • Application Logic — the input to the application
  • Business Logic — application-specific data and behavior for the application
  • Database — long-term data storage for the application

This presentation contains a lot of mysterious terminology for someone new to web applications. It is only intended as a skeleton that you can use to organize information that you encounter later. When learning details of JSF applications, it may be helpful to come back to this presentation to see where the details fit in.


A JSF web application presents a sequence of screens in the user's web browser. Presentation is concerned with the "look" — the visual appearance of those screens. That is, presentation deals with the output side of the JSF application.

The structure of the visual appearance is specified by XHTML files in the NetBeans "Web Pages" development folder. Some of the data can be dynamic, coming from business logic. The source of the dynamic data is specified using Expression Language (EL) in the XHTML file. EL expressions can be identified by their "${" and "}" delimiters.

Styling is specified by Cascading Style Sheet (CSS) files which are usually placed in the resources/css subfolder of the "Web Pages" development folder.

Application Logic

Most screens presented by a JSF application contain forms indicated by <h:form> tags in the XHTML document. These forms normally contain tags specifying widgets in which the user can enter data.

A form also contains one or more buttons or links. When the user clicks on one of these the browser collects the entered data and assembles it into a request that is sent to the server. The JSF framework converts and validates the data.

For successful conversion and validation EL expressions in the form tag of the XHTML document specify which objects in the business logic receive the data.

Application logic handles these cases:

  • It handles navigation, which determines which screen will be presented next. Navigation is specified in the "action" attribute of a form button in an XHTML document. Navigation can also be made dynamic, using EL to invoke business logic methods that specify the next screen.
  • It can determine what is presented to to the user for conversions and validation errors and other types of JSF events.

In short, application logic acts as a controller for a JSF application.

Business Logic

Business logic handles application-specific data and behavior for the application. In JSF, business logic is specified by Java source code files. Java annotations, signaled by an "@" character are used to make some objects accessible in EL expressions. These objects must observe Java Bean conventions for naming accessible attributes and methods.


The database handles long-term data storage for the application. Although the JSF framework does not deal with directly with a database, GlassFish has a built-in Apache Derby database. It can manage connections to Derby and other databases and make them available to JSF as injected resources.

Injected resources are signaled by a "@Injected" annotation in Java source code files. Injected database resources can be accessed using the Java Database Connectivity (JDBC) libraries.

By itself, JDBC operates using Structured Query Language (SQL) code embedded as strings in Java statements. SQL is the most common language used for database access. The embedding of SQL code into Java code is awkward. It can be avoided by using a simple Java class that reads SQL statements from files.