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.
// This method will be called when the JSP engine encounters 
// the start of a tag implemented by this class
public int doStartTag() throws JspTagException {
	// This return value means that the JSP engine 
	// should evaluate the contents and any child 
	//tags of this tag
	return EVAL_BODY_INCLUDE;
}

// This method will be called when the JSP engine encounters 
// the end of a tag implemented by this class
public int doEndTag() throws JspTagException {
	String dateString = new Date().toString();
	try {
	 pageContext.getOut().write("Hello world.<br/>");
	 pageContext.getOut().write("My name is " 
		+ getClass().getName() +
			" and it's " + dateString + "<p/>");
	} catch (IOException ex) {
		throw new JspTagException
			("Fatal error: hello tag could not 
			write to JSP out");
	}	

	// This return value means that the JSP engine should 
	// continue to evaluate the rest of this page
	return EVAL_PAGE;
	}
} // class HelloTag

The tag library descriptor, which we'll name hello.tld, is required to map the tag to the tag handler class and defines the way JSPs may interact with the HelloTag class. The tag library descriptor is an XML document conforming to a DTD specified by Sun Microsystems:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
	PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
	"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
	<tlibversion>1.0</tlibversion>
	<jspversion>1.1</jspversion>
	<shortname>examples</shortname>

	<info>Simple example library.</info>
	
	<tag>
		<name>hello</name>
		<tagclass>tagext.HelloTag</tagclass>
		<bodycontent>JSP</bodycontent>
		<info>Simple example</info>
	</tag>
</taglib>

The tag's suffix when used in JSPs must be hello, and its prefix is examples.

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.