package example_1_tg;

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

public class RequestedServlet extends HttpServlet {
    private static final String CONTENT_TYPE = "text/html;charset=gb2312";
    public void init() throws ServletException {
    }

    public void doGet(HttpServletRequest request,
                      HttpServletResponse response) throws ServletException,
            IOException {
        response.setContentType(CONTENT_TYPE);
        PrintWriter out = response.getWriter();
        HttpSession ses = request.getSession(true);
        out.println("<html>");
        out.println("<head><title>RequestedServlet</title></head>")
                ;
        out.println("<body bgcolor=\"#ffffff\">");
        out.println("<h1>简单的过滤器示例。</h1>");
        out.println("<b>用户名:</b>" + (String) ses.getAttribute("username") +
                    "<br/>");
        out.println("<b>名字:</b>" + (String) ses.getAttribute("firstname") +
                    "<br/>");
        out.println("<b>姓氏:</b>" + (String) ses.getAttribute("lastname"));
        out.println("</body>");
        out.println("</html>");
        out.close();
    }

    public void doPost(HttpServletRequest request,
                       HttpServletResponse response) throws ServletException,
            IOException {
        doGet(request, response);
    }

    public void destroy() {
    }
}
