*
*
*
*
*
*
*
*
*
*
*/
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class PrintCGI extends HttpServlet {
/**
* doGet implementation, calls printCGIValues
*
* @param request
* @param response
* @throws IOException
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException {
printCGIValues(request, response);
}
/**
* doPost implementation, calls printCGIValues
*
* @param request
* @param response
* @throws IOException
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException {
printCGIValues(request, response);
}
/**
* Prints CGI Environment Variables in a table
*
* @param request
* @param response
* @throws IOException
*/
public void printCGIValues(HttpServletRequest request,
HttpServletResponse response) throws IOException {
String headers = null;
String htmlHeader = "
String htmlFooter = "";
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println(htmlHeader);
out.println("
| CGI Variable | Value | ");
|---|---|
| Authentication Type | ");" + request.getAuthType() + " |
| Content Type | ");" + request.getContentType() + " |
| Content Type Length | ");" + request.getContentLength() + " |
| Query String | ");" + request.getMethod() + " |
| IP Address | ");" + request.getRemoteAddr() + " |
| Host Name | ");" + request.getRemoteHost() + " |
| Request URL | ");" + request.getRequestURI() + " |
| Servlet Path | ");" + request.getServletPath() + " |
| Server's Name | ");" + request.getServerName() + " |
| Server's Port | ");" + request.getServerPort() + " |
");
out.println(htmlFooter);
}
}


No comments:
Post a Comment