Evaluates the body of the tag used by the calling page to invoke this tag file.
<jsp:doBody ({var="scopedAttributeName" |
varReader="scopedAttributeName" }
[scope="page | request | session | application" ] />) | />
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.
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.
var="scopedAttributeName"
String object. A translation error must occur if both var and varReader are specified. If neither var nor varReader are specified, the result of the body goes directly to the JspWriter, as described above.
varReader="scopedAttributeName"
java.io.Reader object. A translation error must occur if both var and varReader are specified. If neither var nor varReader is specified, the result of the body invocation goes directly to the JspWriter, as described above.
scope="page | request | session | application"
page, request, session, or application. A translation error results if this attribute appears without specifying either the var or varReader attribute as well. Note that a value of session should be used with caution since not all calling pages may be participating in a session. A container must throw an IllegalStateException at runtime if scope is session and the calling page does not participate in a session. Defaults to page.