• jsp页面获取服务器Ip地址等数据


    废话不多说,直接上代码

    
    <%@ 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_ADDR = request.getLocalAddr();
    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_ADDR", SERVER_ADDR);
    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>
    
    
    
    
    
  • 相关阅读:
    Python自动化开发-基础语法
    Python自动化开发-简介
    Hello World!
    Mongo导出数据文件导致错误 Got signal: 6 (Aborted)解决方法
    PHP快速排序及其时间复杂度
    PHP读某一个目录下所有文件和文件夹
    PHP获得两个绝对路径的相对路径
    awk神器
    PHP使用Mysql事务
    PHP使用session_set_save_handler陷阱
  • 原文地址:https://www.cnblogs.com/userzf/p/11063509.html
Copyright © 2020-2023  润新知