package example_2_lg;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

public class AuthenticationServlet extends HttpServlet {
    private static final String CONTENT_TYPE = "text/html;charset=gb2312";

    //初始化全局变量
    public void init() throws ServletException {
    }

    //处理 HTTP Get 请求
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws
            ServletException, IOException {
        response.setContentType(CONTENT_TYPE);
        PrintWriter out = response.getWriter();
        out.println("<html>");
        out.println("<head><title>AuthenticationServlet</title></head>");
        out.println("<body bgcolor=\"#ffffff\">");
        out.println("<p>servle 已经接收到了一个" + request.getMethod() +
                    ". 这是应答.</p>");
        out.println("</body>");
        out.println("</html>");
        out.close();
    }

    //处理 HTTP Post 请求
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws
            ServletException, IOException {
        doGet(request, response);
    }

    //清除资源
    public void destroy() {
    }
}
