import java.io.*;
import javax.servlet.*;
public class ServletReq extends GenericServlet
{
  public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException
  {
   ServletOutputStream out=res.getOutputStream();
   out.println("<pre>");
   out.println("informtion about servlet request.");
   out.println("request content length:"+req.getContentLength()); 
   out.println("request content type:"+req.getContentType());  //返回形如text/html
   out.println(" request content protocol:"+req.getProtocol());  ////返回形如<protocol>/<version>
   out.println("request sheme:"+req.getScheme());  //返回形如http的串
   out.println("request servername:"+req.getServerName()); //返回形如djf.nudt.edu.cn的串
   out.println("request serverport:"+req.getServerPort()); 
   out.println("request remote address:"+req.getRemoteAddr()); //返回形如202.197.11.163的ip地址
   out.println("request remote host:"+req.getRemoteHost());
   out.println("request parameter name:"+req.getParameter("name"));
   out.println("</pre>");
   }
}

  //输入：http://localhost/sevlet/ServletReq ?name=djf
