/* $Id: RequestInfoExample.java 24-jul-2004.22:16:29 hhildebr Exp $ * */ import java.io.*; import java.text.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; /** * Example servlet showing request information. * * @author James Duncan Davidson */ public class RequestInfoExample extends HttpServlet { ResourceBundle rb = ResourceBundle.getBundle("LocalStrings"); public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); out.println(""); out.println(""); out.println(""); String title = rb.getString("requestinfo.title"); out.println("" + title + ""); out.println(""); out.println(""); // img stuff not req'd for source code html showing // all links relative! out.println(""); out.println("\"view"); out.println(""); out.println("\"return\""); out.println("

" + title + "

"); out.println("
"); out.println(rb.getString("requestinfo.label.method")); out.println(""); out.println(request.getMethod()); out.println("
"); out.println(rb.getString("requestinfo.label.requesturi")); out.println(""); out.println(DemoUtil.HTMLReplace(request.getRequestURI())); out.println("
"); out.println(rb.getString("requestinfo.label.protocol")); out.println(""); out.println(request.getProtocol()); out.println("
"); out.println(rb.getString("requestinfo.label.pathinfo")); out.println(""); out.println(DemoUtil.HTMLReplace(request.getPathInfo())); out.println("
"); out.println(rb.getString("requestinfo.label.remoteaddr")); out.println(""); out.println(request.getRemoteAddr()); out.println("
"); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { doGet(request, response); } }