/* * @(#)StandardHeader * * Copyright (c) 1998 Karl Moss. All Rights Reserved. * * You may study, use, modify, and distribute this software for any * purpose provided that this copyright notice appears in all copies. * * This software is provided WITHOUT WARRANTY either expressed or * implied. * * @author Karl Moss * @version 1.0 * @date 09Mar98 * */ package javaservlets.samples; import javax.servlet.*; /** *
This is a simple server side include servlet that will * format the standard company HTML header. The title of the page * will be set to the value of the title property */ public class StandardHeader extends GenericServlet { /** *
Performs the servlet service * * @param req The request from the client * @param resp The response from the servlet */ public void service(ServletRequest req, ServletResponse resp) throws ServletException, java.io.IOException { // Create a PrintWriter to write the response java.io.PrintWriter out = new java.io.PrintWriter(resp.getOutputStream()); // Get the title of the page. Set to empty string if // no title parameter was given String titles[] = req.getParameterValues("title"); String title = ""; if (titles != null) { if (titles.length > 0) { title = titles[0]; } } // Format the standard header out.println(""); out.println("
"); out.println("Returns information about this servlet */ public String getServletInfo() { return "StandardHeader - Standard company header"; } /** *
Initialize the servlet. This is called once when the * servlet is loaded. It is guaranteed to complete before any * requests are made to the servlet * * @param cfg Servlet configuration information */ public void init(ServletConfig cfg) throws ServletException { super.init(cfg); } /** *
Destroy the servlet. This is called once when the servlet * is unloaded. */ public void destroy() { super.destroy(); } }