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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.