主页 > 知识库 > jsp源码实例3(获取jsp各种参数)

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.
* P>
* Taken from Core Servlets and JavaServer Pages
* from Prentice Hall and Sun Microsystems Press,
* http://www.coreservlets.com/.
* copy; 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 NameTH>Value");
for(int i=0; ivariables.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);
}
}

标签:潮州 玉树 保定 吴忠 绍兴 广元 北海 肇庆

巨人网络通讯声明:本文标题《jsp源码实例3(获取jsp各种参数)》,本文关键词  jsp,源码,实例,获取,各种,;如发现本文内容存在版权问题,烦请提供相关信息告之我们,我们将及时沟通与处理。本站内容系统采集于网络,涉及言论、版权与本站无关。
  • 相关文章
  • 下面列出与本文章《jsp源码实例3(获取jsp各种参数)》相关的同类信息!
  • 本页收集关于jsp源码实例3(获取jsp各种参数)的相关信息资讯供网民参考!
  • 推荐文章