Java Server Pages

Java Server Pages (JSP) start out as an HTML page. JSP adds a handful of JSP directives, scriplets, and expressions.

Java Server Pages must be run on a Web server that is JSP compliant. When the server gets a request for a JSP (file type .jsp), the request is handed off to the JSP engine, which resolves, on the fly, all the JSP tags and information into a Java servelet and then runs the servlet. Once the Web server runs the servlet, the servlet is maintained in cache for subsequent use (unless the source page changes).

Scriplets and Expression Evaluation

Scriplets are bits of Java code that you use to "glue" the parts of your JSP together. Use <% ... %> delimiters to identify the beginning and end of your scriplets.

To evaluate an in-line expression and have its result placed in line with your HTML, place the expression inside <%= ... %> delimiters. The expression is converted to a text String and the result replaces the <%=exp%> sequence.

Note: Expression evaluation tags (<%= ... %>) cannot be nested inside a scriplet (<% ... %>). The scriplet must be terminated first. Similarly, HTML tags can not be nested inside a scriplet. Again the scriplet must be terminated first.

JSP Directives and Tags

JSP directives are used to pass information on processing the page to the JSP engine. Standard JSP tags do the majority of this work, but it is possible to generate custom tag libraries.

The base tag set is shown in the table below:

TagUse
jsp:useBeanDeclares an instance of a JavaBean component
jsp:setPropertySets a property of a JavaBean
jsp:getPropertyRetrieves a JavaBean property
jsp:include Replaces this tag with the contents of the specified file
jsp;forward Forwards a client request to another HTML page, JSP, or Servelet


Maintained by John Loomis, last updated 5 Jan 2001