点击这里给我发消息 点击这里给我发消息

JSP获取服务器参数

添加时间:2013-12-7
    相关阅读: HTML JSP

  Baijinshan.tk代码

  <%@ page language="java" import="java.util.*" pageEncoding="GBK"%>

  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

  <html>

  <head>

  <title>Server Info</title>

  <meta http-equiv="pragma" content="no-cache">

  <meta http-equiv="cache-control" content="no-cache">

  <meta http-equiv="expires" content="0">

  </head>

  <body>

  <%

  String SERVER_NAME = request.getServerName();

  String SERVER_SOFTWARE = getServletContext().getServerInfo();

  String SERVER_PROTOCOL = request.getProtocol();

  Integer SERVER_PORT = request.getServerPort();

  String REQUEST_METHOD = request.getMethod();

  String PATH_INFO = request.getPathInfo();

  String PATH_TRANSLATED = request.getPathTranslated();

  String SCRIPT_NAME = request.getServletPath();

  String DOCUMENT_ROOT = request.getRealPath("/");

  String QUERY_STRING = request.getQueryString();

  String REMOTE_HOST = request.getRemoteHost();

  String REMOTE_ADDR = request.getRemoteAddr();

  String AUTH_TYPE = request.getAuthType();

  String REMOTE_USER = request.getRemoteUser();

  String CONTENT_TYPE = request.getContentType();

  Integer CONTENT_LENGTH = request.getContentLength();

  String HTTP_ACCEPT = request.getHeader("Accept");

  String HTTP_USER_AGENT = request.getHeader("User-Agent");

  String HTTP_REFERER = request.getHeader("Referer");

  HashMap infoMap = new HashMap();

  infoMap.put("SERVER_NAME", SERVER_NAME);

  infoMap.put("SERVER_SOFTWARE", SERVER_SOFTWARE);

  infoMap.put("SERVER_PROTOCOL", SERVER_PROTOCOL);

  infoMap.put("SERVER_PORT", SERVER_PORT);

  infoMap.put("REQUEST_METHOD", REQUEST_METHOD);

  infoMap.put("PATH_INFO", PATH_INFO);

  infoMap.put("PATH_TRANSLATED", PATH_TRANSLATED);

  infoMap.put("SCRIPT_NAME", SCRIPT_NAME);

  infoMap.put("DOCUMENT_ROOT", DOCUMENT_ROOT);

  infoMap.put("QUERY_STRING", QUERY_STRING);

  infoMap.put("REMOTE_HOST", REMOTE_HOST);

  infoMap.put("REMOTE_ADDR", REMOTE_ADDR);

  infoMap.put("AUTH_TYPE", AUTH_TYPE);

  infoMap.put("REMOTE_USER", REMOTE_USER);

  infoMap.put("CONTENT_TYPE", CONTENT_TYPE);

  infoMap.put("CONTENT_LENGTH", CONTENT_LENGTH);

  infoMap.put("HTTP_ACCEPT", HTTP_ACCEPT);

  infoMap.put("HTTP_USER_AGENT", HTTP_USER_AGENT);

  infoMap.put("HTTP_REFERER", HTTP_REFERER);

  Iterator it = infoMap.keySet().iterator();

  %>

  <table border="1">

  <%

  while (it.hasNext()) {

  Object o = it.next();

  %>

  <tr>

  <td>

  <%=o%>

  <td>

  <%=infoMap.get(o)%>

  </td>

  </tr>

  <%

  }

  %>

  </table>

  </body>

  </html>

咨询热线:020-85648757 85648755 85648616 0755-27912581 客服:020-85648756 0755-27912581 业务传真:020-32579052
广州市网景网络科技有限公司 Copyright◎2003-2008 Veelink.com. All Rights Reserved.
广州商务地址:广东省广州市黄埔大道中203号(海景园区)海景花园C栋501室
= 深圳商务地址:深圳市宝源路华丰宝源大厦606
研发中心:广东广州市天河软件园海景园区 粤ICP备05103322号 工商注册