jsp源码实例3(获取jsp各种参数)

js

package coreservlets;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;

/** Creates a table showing the current value of each
* of the standard CGI variables.
* <P>
* Taken from Core Servlets and JavaServer Pages
* from Prentice Hall and Sun Microsystems Press,
* http://www.coreservlets.com/.
* 2000 Marty Hall; may be freely used or adapted.
*/

public class ShowCGIVariables extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String[][] variables =
{ { "AUTH_TYPE", request.getAuthType() },
{ "CONTENT_LENGTH",
String.valueOf(request.getContentLength()) },
{ "CONTENT_TYPE", request.getContentType() },
{ "DOCUMENT_ROOT",
getServletContext().getRealPath("/") },
{ "PATH_INFO", request.getPathInfo() },
{ "PATH_TRANSLATED", request.getPathTranslated() },
{ "QUERY_STRING", request.getQueryString() },
{ "REMOTE_ADDR", request.getRemoteAddr() },
{ "REMOTE_HOST", request.getRemoteHost() },
{ "REMOTE_USER", request.getRemoteUser() },
{ "REQUEST_METHOD", request.getMethod() },
{ "SCRIPT_NAME", request.getServletPath() },
{ "SERVER_NAME", request.getServerName() },
{ "SERVER_PORT",
String.valueOf(request.getServerPort()) },
{ "SERVER_PROTOCOL", request.getProtocol() },
{ "SERVER_SOFTWARE",
getServletContext().getServerInfo() }
};
String title = "Servlet Example: Showing CGI Variables";
out.println(ServletUtilities.headWithTitle(title) +
"<BODY BGCOLOR=\"#FDF5E6\">\n" +
"<H1 ALIGN=\"CENTER\">" + title + "</H1>\n" +
"<TABLE BORDER=1 ALIGN=\"CENTER\">\n" +
"<TR BGCOLOR=\"#FFAD00\">\n" +
"<TH>CGI Variable Name<TH>Value");
for(int i=0; i<variables.length; i++) {
String varName = variables[0];
String varValue = variables[i][1];
if (varValue == null)
varValue = "<I>Not specified</I>";
out.println("<TR><TD>" + varName + "<TD>" + varValue);
}
out.println("</TABLE></BODY></HTML>");
}

/** POST and GET requests handled identically. */

public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}

时间: 2024-09-09 10:00:02

jsp源码实例3(获取jsp各种参数)的相关文章

jsp源码实例2(获取表单参数)

js package coreservlets; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.util.*; /** Shows all the parameters sent to the servlet via either * GET or POST. Specially marks parameters that have * no values or multipl

jsp源码实例3(获取jsp各种参数)_JSP编程

package coreservlets; import java.io.*;import javax.servlet.*;import javax.servlet.http.*;import java.util.*; /** Creates a table showing the current value of each* of the standard CGI variables.* <P>* Taken from Core Servlets and JavaServer Pages*

jsp源码实例5(cookie)

cookie|js package coreservlets; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; /** Sets six cookies: three that apply only to the current * session (regardless of how long that session lasts) * and three that persist for an ho

jsp源码实例4(搜索引擎)

js|搜索引擎 package coreservlets; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.net.*; public class SearchEngines extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throw

jsp源码实例1(输出)

js package coreservlets; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; /** Simple servlet that generates HTML. * <P> * Taken from Core Servlets and JavaServer Pages * from Prentice Hall and Sun Microsystems Press, * http://w

jsp源码实例

js package coreservlets; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.net.*; public class SearchEngines extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws Ser

jsp源码实例5(cookie)_JSP编程

package coreservlets; import java.io.*;import javax.servlet.*;import javax.servlet.http.*; /** Sets six cookies: three that apply only to the current* session (regardless of how long that session lasts)* and three that persist for an hour (regardless

jsp源码实例1(输出)_JSP编程

package coreservlets; import java.io.*;import javax.servlet.*;import javax.servlet.http.*; /** Simple servlet that generates HTML.* <P>* Taken from Core Servlets and JavaServer Pages* from Prentice Hall and Sun Microsystems Press,* http://www.corese

JSP多种web应用服务器导致JSP源码泄漏漏洞_JSP编程

JSP多种web应用服务器导致JSP源码泄漏漏洞 作者:中联绿盟 汉化:不详 整理:JSPER 受影响的系统: BEA Systems Weblogic 4.5.1 - Microsoft Windows NT 4.0 BEA Systems Weblogic 4.0.4 - Microsoft Windows NT 4.0 BEA Systems Weblogic 3.1.8 - Microsoft Windows NT 4.0 IBM Websphere Application Server