Reviews : Java Books :
Professional Java Server Programming J2EE Edition : Chapter 12

Professional Java Server Programming J2EE Edition
Chapter 12

Title: Professional Java Server Programming J2EE Edition
ISBN: 1861004656
US Price: $ 64.99
Canadian Price:
C$ 97.95
UK Price: £ 46.99
Publication Date: September 2000
Pages: 1633
© Wrox Press Limited, US and UK.
<jsp:forward page="next.jsp" />

We can also to add additional parameters to the request before forwarding with an extended usage of <jsp:forward>, which nests one or more <jsp:param> tags within the <jsp:forward> tag: <:RE> <jsp:forward page="next.jsp" >   <jsp:param name="image" value="house.gif" /> </jsp:forward>

Tag extensions allow a vast range of new functionality to be added to the JSP language and they can be invoked in a similarly intuitive way. For example, I could create a tag named <wrox:forward>, specify what attributes and subtags, if any, it requires, and implement it to perform a custom action before forwarding. Not only can this be added simply into the web page, it enforces separation of code and presentation, decouples the call from the class that implements the functionality associated with the tag, and can be simply incorporated into a design tool.

The key concepts in tag extensions are:

Tag name:
A JSP tag is uniquely identifed by a combination of prefix (in this case jsp), and suffix (in this case forward), separated by a colon.
Attributes:
Tags may have attributes, which use the XML syntax for attributes. The <jsp:forward> tag above has one attribute (page), while the <jsp:param> attribute has two (name and value). Attributes may be required or optional.
Nesting:
Note how the <jsp:param> subtag is used in the second example above. Tag extensions can detect nested tags at runtime and cooperate. A tag directly enclosing another tag is called the parent of the tag it encloses: in the example above, the <jsp:forward> tag is the parent of the <jsp:param> tag.
Body content:
This is anything between the start and end elements in a JSP tag, excluding subtags. A tag extension can access and manipulate its body content. Neither the <jsp:forward> nor <jsp:param> tags require body content. We will see later an example of a tag that can reverse its body content. It will be invoked like this (the body content is shown in bold):
<examples:reverse>
  
Able was I ere I saw Elba
The functionality associated with a tag is implemented by one or more Java classes. The tag handler (the class implementing the tag itself) is a JavaBean, with properties matching the tag's XML attributes. A Tag Library Descriptor (TLD) file is an XML document that describes a tag library, which contains one or more tag extensions. The JSP taglib directive must be used to import the tag library's tags in each JSP that wishes to use any of them.

How to Add Java Applets to Your Site

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.