Professional Java Server Programming J2EE Edition Chapter 12
The most interesting methods in the BodyContent class are:
void clearBody()
Clears the body content. Useful if we want to manipulate the body content before writing it out.
JspWriter getEnclosingWriter()
Returns the enclosing JspWriter; this may be the writer of an enclosing tag, or the writer of a JSP itself. We
normally use this method to get a JSP writer to which we can write the body content stored in a body tag
when we have finished manipulating it. For example, we have used the following lines of code in the
doEndTag() method of a number of BodyTag implementations in this chapter:
BodyContent bodyContent = getBodyContent();
if (bodyContent != null) {
bodyContent.getEnclosingWriter().write(sbOut.toString());
}
This ensures that if there is any body content held in the body tag, it will be written to the enclosing JSP writer.
String getString()
This returns the content already held in the body content, as a String. This is useful if we need to examine
what has been added to the body content with each iteration of a loop.
Convenience Classes
Some of the methods in Tag and BodyTag will be implemented the same way in most tags. So the
javax.servlet.jsp.tagext package includes two convenience implementations of Tag and BodyTag:
TagSupport and its subclass BodyTagSupport. Classes implementing tag extensions will normally be
derived from one of these. The class diagram below shows the relationship between these classes and the Tag
and BodyTag interfaces:
New on the Java Boutique:
New Review:
Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling
API boasts simplicity, ease-of-integration, a well-rounded feature
set, and it's free!
New Applet:
Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA
sequences into three useful formats.
Elsewhere on internet.com:
WebDeveloper Java
Lots of Java information on webdeveloper.com
WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.
ScriptSearch Java
Hundreds of free Java code files to download.
jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.
|