Class 2 | Intermediate Java 30-IT-397 |
RowBody.java
// 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 RowBody 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(EVAL_BODY_INCLUDE);
// End the method.
}
public int doEndTag() {
try {
// Get an output stream for our tag's output.
JspWriter out = pageContext.getOut();
// Write the <td> element.
out.print("</td>");
} catch (IOException
e) {
System.out.println("Error in Row: " + e.getMessage());
}
return(EVAL_PAGE);
}
public void setColor(String color) {
this.color = color;
}
// End the class.
}
Created by: Brandan Jones December 17, 2001