I am pretty new to custom tag creation in JSP. When I went through some tutorials, I saw them using EVAL_BODY_AGAIN, SKIP_BODY and EVAL_BODY_INCLUDE
tags. Can anyone tell me what it actually means and what is it for?
Asked
Active
Viewed 2,798 times
1

sreehari
- 189
- 6
- 16
-
Google for `jsp custom tag EVAL_BODY_AGAIN SKIP_BODY EVAL_BODY_INCLUDE`. – Jozef Chocholacek Feb 28 '17 at 12:45
-
What links did you refer? – Shivam Aggarwal Mar 17 '17 at 12:28
1 Answers
4
SKIP_BODY : It is an optional returned value but this value must be returned by doStartTag() when you want to skip the body evaluation that is it must be returned when the TagLibraryDescriptor file contains the element empty, the value "empty" shows that there will always be an empty action.
EVAL_BODY_INCLUDE : It is an optional returned value but this value must be returned by the doStartTag() when you want to evaluate the body.
Example :
consider a class DoStartTagExample.java
package pack;
import javax.servlet.jsp.tagext.TagSupport;
public class DoStartTagExample extends TagSupport
{
public int doStartTag()
{
//return EVAL_BODY_INCLUDE;
return SKIP_BODY;
}
}
This is a sample tld called doStartTagExample.tld
<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>2.0</jsp-version>
<tag>
<name>doStart</name>
<tag-class>pack.DoStartTagExample</tag-class>
<body-content>empty</body-content>
</tag>
</taglib>
now write a jsp doStartTagExample.jsp
<%@taglib uri="/WEB-INF/doStartTagExample.tld" prefix="dev" %>
<html>
<head>
<title>doStartTag() Example</title>
</head>
<body>
Jsp page content before starting tag.
<dev:doStart>
<br><b>contents displayed after the custom tag's
start tag is encountered.</b>
</dev:doStart>
<br>Jsp page content after closing tag.
</body>
</html>
Output will be as follows

vinay j
- 199
- 11