Contents | Prev | Next


<jsp:doBody>

Evaluates the body of the tag used by the calling page to invoke this tag file.

JSP Syntax

<jsp:doBody ({var="scopedAttributeName"  |    	
    varReader="scopedAttributeName" }  	
   [scope="page | request | session | application" ] />) | />

XML Syntax

Same as JSP syntax.

Examples

This example tag file encapsulates the double custom tag

<%-- double.tag --%>
<jsp:doBody />
<jsp:doBody />

It includes two jsp:doBody tags, which will each invoke the body of the custom double tag in any JSP that includes the tag.

This example JSP page uses the custom double tag to output the text included in the body of the tag two times.

<%-- a.jsp --%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<tags:double>
  This text will be printed twice.<br>
</tags:double>

The result will be the output:

This text will be printed twice.
This text will be printed twice.

Description

The jsp:doBody standard action can only be used in tag files. It invokes the body of the tag, sending the output of the result to the JspWriter, or to a scoped attribute that can be examined and manipulated.

The jsp:doBody standard action behaves exactly like jsp:invoke, except that it operates on the body of the tag instead of on a specific fragment passed as an attribute. Because it always operates on the body of the tag, there is no name attribute for this standard action.

Fragments are provided access to variables the same way for jsp:doBody as they are for jsp:invoke. If no body was passed to the tag, jsp:doBody will behave as though a body was passed in that produces no output.

The body of a tag is passed to the simple tag handler as a JspFragment object. A translation error shall result if the jsp:doBody action contains a nonempty body.

The result of evaluating the tag body is sent to the response or is stored in an EL variable for later manipulation. To store the result of evaluating a fragment to an EL variable, you specify the var or varReader attribute. If var is specified, the container stores the result in an EL variable of type String with the name specified by var. If varReader is specified, the container stores the result in an EL variable of type java.io.Reader, with the name specified by varReader. The Reader object can then be passed to a custom tag for further processing. A translation error occurs if both var and varReader are specified. An optional scope attribute indicates the scope of the resulting variable. The possible values are page (default), request, session, or application. A translation error occurs if you use this attribute without specifying the var or varReader attribute.

Attributes



Contents | Prev | Next

Copyright © 2004, Sun Microsystems, Inc. All rights reserved.