JRunDemoServlet.java

/**
 * JRunDemoServlet
 * 
 * Define standard look and feel of JRun demo servlets.
 * This is the base servlet class for all JRun demo servlets.
 * This servlet is declared abstract so it is not directly executable.
 * Subclasses of this servlet must overload some of the doXXX() methods
 * to give this servlet response generation capabilities.
 * 
 * by Paul Colton
 * (c) 1999 Allaire Corporation
 */

import java.io.PrintWriter;

import javax.servlet.*;
import javax.servlet.http.*;

public abstract class JRunDemoServlet extends HttpServlet {
	final static String TITLE_COLOR = "#8FBC8F";
	final static String ROW_COLOR = "#FAFAD2";
	final static String ROW_ALT_COLOR ="#FFFFFF";
	
	// Writes HTML for standard page header.
	protected void generateDemoPageStart( PrintWriter out ) {
		out.println( "<HTML>" );
		out.println( "<HEAD><TITLE>" + getServletInfo() + "</TITLE></HEAD>" );
		out.println( "<BODY BGCOLOR=\"" + ROW_ALT_COLOR + "\">" );
		out.println( "<CENTER>" );
			out.println( "<TABLE BORDER=0 CELLPADDING=2><TR BGCOLOR=\"" + TITLE_COLOR + "\"><TD>" );
				out.println( "<TABLE BORDER=0><TR BGCOLOR=\"" + ROW_COLOR + "\"><TD>" );
				out.println( "<FONT SIZE=+1 FACE=\"arial\">" + getServletInfo() + "</FONT>" );
			out.println( "</TD></TR></TABLE>" );
		out.println( "</TD></TR></TABLE>" );
		out.println( "</CENTER><P>" );
	}
	
	// Writes HTML for standard page footer.
	protected void generateDemoPageEnd( HttpServletRequest req, HttpServletResponse res, PrintWriter out ) {
res.setContentType( "text/html; charset=euc-jp" );
		out.println( "<A HREF=\"" + req.getContextPath() + "/servlets/\">サーブレットの例に戻ります。</A>" );
		out.println( "</BODY>" );
		out.println( "</HTML>" );
	}
	
	public void init( ServletConfig config ) throws ServletException {
		super.init( config );
	}
	
	public void destroy() {
		super.destroy();
	}
	
	public String getServletInfo() {
		return this.getClass().getName();
	}
}