import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; // File: EchoEnvironmentServlet.java // Listing 2 // /** * This servlet displays the CGI environment variables in a web page. * * @author Chad (shod) Darby, darby@j-nine.com * @version 3.41, 2 Nov 1997 * */ public class EchoEnvironmentServlet extends HttpServlet { public void service(HttpServletRequest request, HttpServletResponse response) throws IOException { String replyPage = null; // Build the header for HTML page // replyPage = "
Server Name: " + request.getServerName(); replyPage += "
Server Port: " + request.getServerPort(); replyPage += "
Server Protocol: " + request.getProtocol(); replyPage += "
Servlet Name: " + request.getServletPath(); replyPage += "
Method: " + request.getMethod(); replyPage += "
Path Info: " + request.getPathInfo(); replyPage += "
Path Translated: " + request.getPathTranslated(); replyPage += "
Query String: " + request.getQueryString(); replyPage += "
Request URI: " + request.getRequestURI(); replyPage += "
Remote Host: " + request.getRemoteHost(); replyPage += "
Remote Addr: " + request.getRemoteAddr(); replyPage += "
Remote User: " + request.getRemoteUser(); replyPage += "
Authorization Type: " + request.getAuthType(); replyPage += "
Content Type: " + request.getContentType(); replyPage += "
Content Length: " + request.getContentLength(); replyPage += "
" + name + ": " + request.getHeader(name); } replyPage += "