servlet头
package project_servlet;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class StandardHeader extends GenericServlet {
/*
*<P>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("<html>");
out.print("head");
out.println("<title>"+title+"</title>");
out.println("</head>");
out.println("</head>");
out.println("<body>");
out.println("<img aligh=\"right\"");
out.println("src=\"images\\CompanyLogo.jpg\"");
out.println("alt=\"Company Logo\">");
out.println("<font size=\"4\" face=\"Arial\" color=\"red\">");
out.println("<br><br>");
out.println("<strong>"+title+"<strong></font>");
out.println("<br><hr><br>");
//Wrap up
out.flush();
out.close();
}
}
package project_servlet;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class StandardHeader extends GenericServlet {
/*
*<P>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("<html>");
out.print("head");
out.println("<title>"+title+"</title>");
out.println("</head>");
out.println("</head>");
out.println("<body>");
out.println("<img aligh=\"right\"");
out.println("src=\"images\\CompanyLogo.jpg\"");
out.println("alt=\"Company Logo\">");
out.println("<font size=\"4\" face=\"Arial\" color=\"red\">");
out.println("<br><br>");
out.println("<strong>"+title+"<strong></font>");
out.println("<br><hr><br>");
//Wrap up
out.flush();
out.close();
}
}
package project_servlet;import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;public class StandardFooter extends GenericServlet {
/*
*<P>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());
//Format the standard Footer
out.println("<br><hr>");
out.println("<a href=\"mailto:[email protected]\">");
out.println("img src=\"images\\mailbox.gif\"");
out.println("< alt=\"mailbox\">");
out.println("</a>");
out.println("<font size=\"-1\">");
out.println("<i>Questions or Comments?</i></font>");
out.println("</body>");
out.println("</html>");
//Wrap up
out.flush();
out.close();
}}