Action Elements
Actions are executed when the JSP page is requested by a client. They are inserted in a page using XML element syntax, and encapsulate functionality such as input validation using beans, database access, or passing control to another page. The JSP specification defines a few standard action elements, described in this section, and also includes a framework for developing custom action elements.
An action element consists of a start tag (optionally with attributes), a body, and an end tag. Other elements can be nested in the body. Here’s an example:
<jsp:forward page="nextPage.jsp"> <jsp:param name="aParam" value="aValue" /> </jsp:forward>
If the action element doesn’t have a body, a shorthand notation
can be used in which the start tag ends with />
instead of >, as shown by the
<jsp:param> action in this example. The
action element name and attribute names are case-sensitive.
Some action attributes accept a request-time attribute value, using the JSP expression syntax:
<% String headerPage = currentTemplateDir + "/header.jsp"; %> <jsp:include page="<%= headerPage %>" />
The attribute descriptions for each action in this section define whether a request-time attribute value is accepted or not.
<jsp:fallback>
The <jsp:fallback>
action can only be
used in the body of a <jsp:plugin> action.
Its body is used to specify the template text to use for browsers
that do not support the HTML <embed> or
<object> elements. This action supports no
attributes.
Example:
<jsp:plugin type="applet" ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access