Show TOC

Developing JSP PagesLocate this document in the navigation structure

Use

JSP enables you to produce dynamic content for the presentation layer in a Web application. More information about the JSP lifecycle and its phases: JSP Life Cycle .

A JSP page consists of elements and template text. Elements are instances of element types known to the Web container. Template text is any non-JSP code. Elements are encapsulated into template text, usually static HTML. The Java Server Pages Specification defines the following syntax elements:

  • Scripting elements

    You use scripting elements to generate dynamic content. There are three types of scripting elements.

    • Expressions - Java expressions evaluated at request processing time. The result of an expression is inserted in the HTML output.

    • Scriptlets - valid Java code fragments executed at request processing time

    • Declarations - used for declaring Java variables and methods and are initialized at JSP page initialization time

  • Directives

    You use directives to pass global information to the Web Container during the translation and compilation phases. The directives are: page , taglib , and include . For tag files we also have: tag , attribute , variable .

  • Actions

    You use standard actions to manipulate Java objects. Actions are processed at request processing time.

The specification also defines a set of implicit objects available for use within scriptlets and scriptlet expressions through scripting variables that are declared implicitly at the beginning of the page. More information: Implicit Objects .

The JSP technology also comes with the JSTL libraries, a collection of actions representing many common tasks, such as writing output, communicating with a database, an so on. To use the JSTL libraries, you only import them with the taglib directive in your JSP pages. More information: JSTL .

Java EE 5 also provides an integration of the former JSF Expression Language and JSP Expression Language into one Unified Expression Language (EL). The Unified EL supports scriptless JSP development, user-defined functions, and deferred evaluation of expressions.

More information about the EL: Unified Expression Language .

More information about JSP syntax: JSP Syntax Elements Outline .

Procedure
  1. In the Developer Studio, use the JSP wizard to create the stubs of the JSP page.

    More information: Creating JSP Files in the Developer Studio .

  2. Using the JSP syntax elements, develop the embedded programming logic, mixed with static HTML and JavaScript content.