/* $Id: RequestHeaderExample.java 24-jul-2004.22:16:28 hhildebr Exp $ * */ import java.io.*; import java.text.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; /** * Example servlet showing request headers * * @author James Duncan Davidson */ public class RequestHeaderExample extends HttpServlet { ResourceBundle rb = ResourceBundle.getBundle("LocalStrings"); public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println(""); out.println(""); out.println(""); String title = rb.getString("requestheader.title"); out.println("" + title + ""); out.println(""); out.println(""); // all links relative out.println(""); out.println("\"view"); out.println(""); out.println("\"return\""); out.println("

" + title + "

"); out.println(""); Enumeration e = request.getHeaderNames(); while (e.hasMoreElements()) { String headerName = (String) e.nextElement(); String headerValue = request.getHeader(headerName); out.println(""); } out.println("
" + headerName); out.println("" + headerValue + "
"); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { doGet(request, response); } }