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" />

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.


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.


<jsp:plugin type="applet" ...

Get Java Server Pages now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.