Javaserver Pages Article Index for
Javaserver
Articles about
Javaserver Pages
Website Links For
Javaserver Pages
 

Information About

Javaserver Pages




The JSP syntax adds additional XML tags, called JSP actions, to be used to invoke built-in functionality. Additionally, the technology allows for the creation of JSP tag libraries that act as extensions to the standard HTML or XML tags. Tag libraries provide a Platform Independent way of extending the capabilities of a Web Server .

JSPs are compiled into Java Servlet s by a JSP Compiler . A JSP compiler may generate a servlet in Java code that is then compiled by the Java compiler, or it may generate Byte Code for the servlet directly. In either case, it is helpful to understand how the JSP compiler transforms the page into a Java servlet. For an example, consider the input Here , and its resulting generated Java Servlet Here .


JSP AND SERVLETS


Architecturally speaking, JSP can be viewed as a high-level abstraction of servlets that is implemented as an extension of the Servlet 2.1 API. Both servlets and JSPs were originally developed by Sun Microsystems . Starting with version 1.2 of the JSP specification, JavaServer Pages have been developed under the Java Community Process . JSR 53 defines both the JSP 1.2 and Servlet 2.4 specifications and JSR 152 defines the JSP 2.0 specification. As Of 2006 the JSP 2.1 specification is being developed under JSR 245.


JSP SYNTAX


A JavaServer Page may be broken down into the following pieces:

  • static data such as HTML

  • JSP directives such as the include directive

  • JSP scripting elements and variables

  • JSP actions

  • custom tags



Static data


''Static'' data is written out to the HTTP response exactly as it appears in the input file. Thus a valid JSP input would be a normal HTML page with no embedded java or actions. In that case, the same data would be sent in the response each and every time by the web server.


JSP directives


JSP directives control how the JSP compiler generates the Servlet . The following directives are available:

  • include – The include directive informs the JSP compiler to include a complete file into the current file. It is as if the contents of the included file were pasted directly into the original file. This functionality is similar to the one provided by the C Preprocessor .

  •     <%@ include file="somefile.ext" %>

  • page – There are several options to the page directive.