Class 2 Intermediate Java 30-IT-397  

Row.class

package table;
 

// 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 Row extends TagSupport {

    String color = "#000000";
 
    // 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 the <td> element.
            out.print("<td bgcolor = " + color + ">");
 
            // In case we have an error...
        } catch (IOException e) {
            System.out.println("Error in Row: " + e.getMessage());
        }
 
        // Tell it that we don't need to look at the contents between the tags.
        return(SKIP_BODY);

    // End the method.
    }
 
    public void setColor(String color) {
        this.color = color;
    }

// End the class.
}

 Back

Created by:  Brandan Jones December 17, 2001