Python语言技术文档

微信小程序技术文档

php语言技术文档

jsp语言技术文档

asp语言技术文档

C#/.NET语言技术文档

html5/css技术文档

javascript

点击排行

您现在的位置:首页 > 技术文档 > jsp入门教程

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

来源:中文源码网    浏览:168 次    日期:2024-05-16 13:14:39
【下载文档:  jsp源码实例3(获取jsp各种参数).txt 】


jsp源码实例3(获取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.*

* 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) +"\n" +"

" + title + "

\n" +"\n" +"\n" +"
CGI Variable NameValue");for(int i=0; i" + varName + "" + varValue);}out.println("
");}/** POST and GET requests handled identically. */public void doPost(HttpServletRequest request,HttpServletResponse response)throws ServletException, IOException {doGet(request, response);}}

相关内容