package com;
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class servletTest extends HttpServlet ...{
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException ...{
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
//TODO output your page here
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet servletTest</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet servletTest at " + request.getContextPath () + "</h1>");
out.println("<body>");
out.println(getServletInfo());
out.println("</html>");
//
out.close();
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException ...{
processRequest(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException ...{
processRequest(request, response);
}
public String getServletInfo() ...{
return "Short description";
}
// </editor-fold>
}
本文转自 netcorner 博客园博客,原文链接:http://www.cnblogs.com/netcorner/archive/2012/07/03/2911906.html ,如需转载请自行联系原作者