10.5. Ein einfaches Tag mit Body
Muss das Tag einen Body haben, ist im TLD die entsprechende <body-content>-Deklaration erforderlich sowie eine besondere Anweisung in der Methode doTag().
Die JSP, die das Tag verwendet
<%@ taglib prefix="dieTags" uri="einfacheTags" %> <html><body> Einfaches Tag 2: <dieTags:einfach2> Das ist der Body </dieTags:einfach2> </body></html>
Die Tag-Handler-Klasse
package foo; import javax.servlet.jsp.JspException; import javax.servlet.jsp.tagext.SimpleTagSupport; import java.io.IOException; public class EinfachesTag2 extends SimpleTagSupport { public void doTag() throws JspException, IOException { getJspBody().invoke(null); } }
Das sagt: »Verarbeite den Body des Tags und gib ihn in die Antwort aus.« Das Argument null ...
Get Servlets und JSPs™ von Kopf bis Fuß now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.