Class 2 Intermediate Java 30-IT-397  

Tag Handler Class

// import the necessary libraries.
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;

/**
 * Simple custom JSP tag that prints a copyright where inserted.
 *
 * 12/18/2001 jonesbr@email.uc.edu
 **/

public class CopyrightTag extends TagSupport {

    // method acts when the first tag is reached.
    public int doStartTag() {

        try {
            // Get an output stream for our tag's output.
            JspWriter out = pageContext.getOut();

            // Write our copyright notice.
            // Split into multiple lines for clarity purposes only.
            // Copy into one line for actual use.
            out.print("Created by:" +
                "<a href = \"mailto:jonesbr@email.uc.edu\">Brandan Jones</a>" +
                "December 18, 2001");

            // In case we have an error...
        } catch (IOException e) {
            System.out.println("Error in CopyrightTag: " + e.getMessage());
        }

        // Tell it that we don't need to look at the contents between the tags.
        return(SKIP_BODY);

    // End the method.
    }

// End the class.
}

 The Tag Library Descriptor File

Created by:  Brandan Jones December 17, 2001