/******************************************
environment.java
Servletti-esimerkki, joka vastaa sekä GET- että POST-metodilla
kutsuttaessa ja palauttaa WWW-selaimelle listan ympäristömuuttujista.
Tekijä: Pekka Malmirae, 12/1999
******************************************/
package omatServletit;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class environment extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
kirjoitaHTMLAlku("Ympäristömuuttujien testaus", out);
out.println("Server Name: "+req.getServerName()+"
");
out.println("Server Software: "+getServletContext().getServerInfo()+"
");
out.println("Server Protocol: "+req.getProtocol()+"
");
out.println("Server Port: "+req.getServerPort()+"
");
out.println("Request Method: "+req.getMethod()+"
");
out.println("Path Info: "+req.getPathInfo()+"
");
out.println("Path Translated: "+req.getPathTranslated()+"
");
out.println("Script Name: "+req.getServletPath()+"
");
out.println("Document Root: "+req.getRealPath("/")+"
");
out.println("Query String: "+req.getQueryString()+"
");
out.println("Remote Host: "+req.getRemoteHost()+"
");
out.println("Remote Addr: "+req.getRemoteAddr()+"
");
out.println("Auth Type: "+req.getAuthType()+"
");
out.println("Remote User: "+req.getRemoteUser()+"
");
out.println("Content Type: "+req.getContentType()+"
");
out.println("Content Length: "+req.getContentLength()+"
");
out.println("HTTP Accept: "+req.getHeader("Accept")+"
");
out.println("HTTP User Agent: "+req.getHeader("User-Agent")+"
");
out.println("HTTP Referer: "+req.getHeader("Referer")+"
");
kirjoitaHTMLLoppu(out);
}
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
doGet(req,res);
}
private void kirjoitaHTMLAlku(String otsikko, PrintWriter out)
{
out.println("");
out.println("