Welcome to i-Lab Limited
import java.io.*;
import java.util.Date;
import java.util.Vector;
import javax.servlet.http.HttpServlet;
/** This class extends HttpServlet to provide a suite of convenience methods for
* generating HTML output. The class remembers tags that have been left open and
* these can be programmatically closed by calling {@link #closeTags}. The first
* method called should be {@link #head} and the last should be {@link #finish}.
* @author K.Furnell
* @version $Revision$
*/
public class HtmlServlet extends HttpServlet {
protected static final String COLOUR_BLACK = "#000000";
private PrintWriter output;
/** Record of the currently open tags */
private Vector openTags = new Vector();
/** This method outputs the head content, it must be called (once) before any
* other methods so that the reference to the PrintWriter is stored.
* @param writer the PrintWriter to output to
* @param title the title for the page
* @param product string to place in the "generator" meta-tag and comments
* @see #finish
*/
protected void head(PrintWriter writer, String title, String product, String stylesheet) {
this.output = writer;
write("");
writeNewLineChars();
writeTag("html");
writeTag("head");
if (title != null) {
writeTag("title");
write(title);
closeTag(true); // title
}
writeTag("link", new Pair[] { new Pair("rel", "stylesheet"),
new Pair("href", stylesheet),
new Pair("type", "text/css")}, false);
writeTag("meta", new Pair[] { new Pair("http-equiv","Content-Type"),
new Pair("content", "text/html; charset=iso-8859-1")}, false);
writeNewLineChars();
writeTag("meta", new Pair[] { new Pair("generator", product)}, false);
closeTag(true);
}