package example_lg_part_1;
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);
        ses.setAttribute("ContentType", String.valueOf(request.getContentType()));
        String protocol = (String) ses.getAttribute("Protocol");
        String remotehost = (String) ses.getAttribute("RemoteHost");
        String contentlength = (String) ses.getAttribute("ContentLength");
        String servername = (String) ses.getAttribute("ServerName");
        String remoteaddr = (String) ses.getAttribute("RemoteAddr");
        String username = (String) ses.getAttribute("username");
        out.println("<HTML>");
        out.println("<HEAD><TITLE>RequestedServlet</TITLE></HEAD>");
        out.println("<BODY bgcolor=\"#ffffff\">");
        out.println("<H3>检索到的详细信息</H3>");
        out.println("<B>使用的协议： </B>" + protocol + "<BR/>");
        out.println("<B>远程主机： </B>" + remotehost + "<BR/>");
        out.println("<B>内容长度： </B>" + contentlength + "<BR/>");
        out.println("<B>服务器名称： </B>" + servername + "<BR/>");
        out.println("<B>远程地址： </B>" + remoteaddr + "<BR/>");
        out.println("<B>用户名： </B>" + username + "<BR/>");
        out.println("</BODY>");
        out.println("</HTML>");
        out.close();
    }
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
        doGet(request, response);
    	}
    	public void destroy() 
{ }
}
