Copy Code code as follows:
<%@ page language= "java" import= "java.util.*" pageencoding= "UTF-8"%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<title>jsp and Jstl get server parameters </title>
<body>
JSP Way <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 mode <br/>
${pagecontext.request} | Get the Request object <br>
${pagecontext.session} | Get Session Object <br>
${pagecontext.request.querystring} | Get the requested parameter string <br>
${pagecontext.request.requesturl} | Gets the requested URL, but does not include the requested parameter string <br>
${pagecontext.request.contextpath} | The name of the Web application for the service <br>
${pagecontext.request.method} | Methods for getting HTTP (get, POST) <br>
${pagecontext.request.protocol} | Get used protocol (http/1.1, http/1.0) <br>
${pagecontext.request.remoteuser} | Get user name <br>
${pagecontext.session.new} | Determine if the session is new, called a new session, indicates that the server has just been generated and the client has not yet used the <br>
${pagecontext.session.id} | Get the id<br> of the session
${header["user-agent"]}| user browser version <br/>
${header["Host"]}| Ip<br/>
${PAGECONTEXT.REQUEST.REMOTEADDR} | Get the user's IP address <br>
${pagecontext.servletcontext.serverinfo}| access to host-side service information <br>
${pagecontext.request.serverport}| Port Information <br>
${pagecontext.request.servername}| Server name <br>
${pagecontext.request.remotehost}| Client Name <br>
</body>