| JSP Element |
Syntax |
Interpretation |
Notes |
| JSP Expression |
<%= expression %> |
Expression is evaluated and placed in output. |
XML equivalent is
<jsp:expression> expression
</jsp:expression>. Predefined variables
are request, response,
out, session, application,
config, and pageContext
(available in scriptlets also). |
| JSP Scriptlet |
<% code %> |
Code is inserted in service method. |
XML equivalent is
<jsp:scriptlet> code
</jsp:scriptlet>. |
| JSP Declaration |
<%! code %> |
Code is inserted in body of servlet class,
outside of service method. |
XML equivalent is
<jsp:declaration> code
</jsp:declaration>. |
JSP page Directive |
<%@ page att="val" %> |
Directions to the servlet engine about general setup. |
XML equivalent is
<jsp:directive.page att="val"\>.
Legal attributes, with default values in bold, are:
- import="package.class"
- contentType="MIME-Type"
- isThreadSafe="true|false"
- session="true|false"
- buffer="sizekb|none"
- autoflush="true|false"
- extends="package.class"
- info="message"
- errorPage="url"
- isErrorPage="true|false"
- language="java"
|
JSP include Directive |
<%@ include file="url" %> |
A file on the local system to be included when the JSP page
is translated into a servlet. |
XML equivalent is
<jsp:directive.include
file="url"\>.
The URL must be a relative one. Use the
jsp:include action to include a file at
request time instead of translation time. |
| JSP Comment |
<%-- comment --%> |
Comment; ignored when JSP page is translated into servlet. |
If you want a comment in the resultant HTML, use regular
HTML comment syntax of
<-- comment -->. |
The jsp:include Action |
<jsp:include
page="relative URL"
flush="true"/> |
Includes a file at the time the page is requested. |
If you want to include the file at the time the page
is translated, use the page directive with the
include attribute instead. Warning: on some servers,
the included file must be an HTML file or JSP file, as determined by the
server (usually based on the file extension). |
The jsp:useBean Action |
<jsp:useBean att=val*/> or
<jsp:useBean att=val*>
...
</jsp:useBean> |
Find or build a Java Bean. |
Possible attributes are:
- id="name"
- scope="page|request|session|application"
- class="package.class"
- type="package.class"
- beanName="package.class"
|
The jsp:setProperty Action |
<jsp:setProperty att=val*/> |
Set bean properties, either explicitly or by
designating that value comes from a request parameter. |
Legal attributes are
- name="beanName"
- property="propertyName|*"
- param="parameterName"
- value="val"
|
The jsp:getProperty Action |
<jsp:getProperty
name="propertyName"
value="val"/> |
Retrieve and output bean properties. |
|
The jsp:forward Action |
<jsp:forward
page="relative URL"/> |
Forwards request to another page. |
|
The jsp:plugin Action |
<jsp:plugin
attribute="value"*>
...
</jsp:plugin> |
Generates OBJECT or EMBED tags,
as appropriate to the browser
type, asking that an applet be run using the Java Plugin. |
|