15.2. Writing a Simple Custom Tag

In this section we walk through the entire process of writing and deploying a custom tag. We'll start with the tag definition itself, Message.java, which just prints a message to the browser.

15.2.1. Message.java

 /* * File: Message.java * Purpose: demo simple custom tag by displaying message * passed in custom tag attribute. */ package javaforcf.ch15; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; public class MessageTest extends TagSupport { private String message=""; public void setMessage(String m) { this.message = m; } public String getMessage() { return message; } public int doStartTag() throws JspException { try { pageContext.getOut().print("Hello" + this.getMessage()); } catch (Exception ...

Get Java™ for ColdFusion® Developers 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.