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 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.
<%= ... %>
) 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 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:
Tag | Use |
---|---|
jsp:useBean | Declares an instance of a JavaBean component |
jsp:setProperty | Sets a property of a JavaBean |
jsp:getProperty | Retrieves 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