Print? <% @ Page language = "java" import = "java. util. *" pageEncoding = "UTF-8" %>
<! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN">
<Html>
<Head>
<Title> JSP and JSTL obtaining server parameters </title>
</Head>
<Body>
JSP method <br/>
<%
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 ();
%>
<%
While (it. hasNext ()){
Object o = it. next ();
%>
<% = O %>
<% = InfoMap. get (o) %>
<% Out. println ("<br>") ;}%>
<Br/>
JSTL method <br/>
$ {PageContext. request} | get the request object <br>
$ {PageContext. session} | obtains the session object. <br>
$ {PageContext. request. queryString} | obtains the request parameter string. <br>
$ {PageContext. request. requestURL} | obtains the request URL, but does not include the request parameter string. <br>
$ {PageContext. request. contextPath} | Name of the Service's web application <br>
$ {PageContext. request. method} | get http (GET, POST) <br>
$ {PageContext. request. protocol} | used protocol (HTTP/1.1, HTTP/1.0) <br>
$ {PageContext. request. remoteUser} | get the user name <br>
$ {PageContext. session. new} | judge whether the session is new. The so-called new session indicates that the session was generated by the server and the client is not used yet <br>
$ {PageContext. session. id} | obtains the session ID. <br>
$ {Header ["User-Agent"]} | version of the User's browser <br/>
$ {Header ["Host"]} | IP <br/>
$ {PageContext. request. remoteAddr} | obtains the user's IP address. <br>
$ {PageContext. servletContext. serverInfo} | obtains the service information of the host. <br>
$ {PageContext. request. serverPort} | Port Information <br>
$ {PageContext. request. serverName} | Server name <br>
$ {PageContext. request. remoteHost} | client name <br>
</Body>
</Html>