tags:

views:

141

answers:

2

I couldn't figure how I can manipulate the body content before its first evaluation. Someone knows how to?

[I did succeed manipulating it after the first evaluation, using the BodyTagSupport class by overriding the doAfterBody() method].

A: 

I am a bit unsure of what you want to do since the jsp tag is basically compiled into code. But the tag (and its body) produces an output which is known as a jsp fragment, and this can be manipulated.

Pardon for using the simple tag syntax but you can basically use the

<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

This defines a variable that you can manipulate with other functions. You can later emit the contents of this variable to the output stream.

krosenvold
+1  A: 

You may be looking for BodyTag.doInitBody()

Prepare for evaluation of the body. This method is invoked by the JSP page implementation object after setBodyContent and before the first time the body is to be evaluated. This method will not be invoked for empty tags or for non-empty tags whose doStartTag() method returns SKIP_BODY or EVAL_BODY_INCLUDE.

Michael Glenn