1. JSP code:
Copy codeThe Code is as follows:
<% --
Document: index
Created on:, 12:45:43
Author: lucifer
-- %>
<% @ Page contentType = "text/html" pageEncoding = "UTF-8" %>
<! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN"
Http://www.w3.org/TR/html4/loose.dtd>
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
<Title> JSP Page </title>
</Head>
<Body>
Get Scheme:
<% = Request. getScheme () %>
<Br>
Get Protocol:
<% = Request. getProtocol () %>
<Br>
Get Remote Address:
<% = Request. getRemoteAddr () %>
<Br>
Get Remote Host:
<% = Request. getRemoteHost () %>
<Br>
Get Server Name:
<% = Request. getServerName () %>
<Br>
Get Server Port:
<% = Request. getServerPort () %>
<Br>
Get Header:
<% = Request. getHeader ("User-agent") %>
<Br>
Get Method:
<% = Request. getMethod () %>
<Br>
Get Request's URL:
<% = Request. getServletPath () %>
<Br>
Get Request URI:
<% = Request. getRequestURI () %>
<Br>
Get Request Session ID:
<% = Request. getRequestedSessionId () %>
</Body>
</Html>
2. Output:
Get Scheme: http
Get Protocol: HTTP/1.1
Get Remote Address: 0: 0: 0: 0: 0: 0: 0: 1
Get Remote Host: 0: 0: 0: 0: 0: 0: 0: 1
Get Server Name: localhost
Get Server Port: 8084
Get Header: Mozilla/5.0 (Windows; U; Windows NT 6.0; zh-CN; rv: 1.9.1.3) Gecko/20090824 Firefox/3.5.3
Get Method: GET
Get Request's URL:/Requests. jsp
Get Request URI:/TestRequest/Requests. jsp
Get Request Session ID: 6EF4EB4A3FE39A15EEBD4D46FBD0BA32