- 论坛徽章:
- 0
|
具体的方法可以看看java ee的文档啊,文档里面都有的。
首先,搜索jsp client ip 等关键字就可以找到下列代码:
out.print( request.getRemoteAddr() );
out.print( request.getRemoteHost() );
经过搜索
这个request应该是 HttpServletRequest,所以文档在 http://java.sun.com/j2ee/sdk_1.3 ... ServletRequest.html
然后可以自己尝试一下用request.xxxxx来获取不同的信息。我找到一个列表以供参考
<ul>
CGI Variable Servlet Request Method
<li>SERVER_SOFTWARE ?
<li>SERVER_NAME HttpServletRequest.getServerName()
<li>GATEWAY_INTERFACE N/A The revision of the CGI specification to which
this server complies. Format: CGI/revision
<li>SERVER_PROTOCOL HttpServletRequest.getProtocol()
<li>SERVER_PORT HttpServletRequest.getServerPort()
<li>REQUEST_METHOD HttpServletRequest.getMethod()
<li>PATH_INFO HttpServletRequest.getPathInfo()
<li>PATH_TRANSLATED HttpServletRequest.getPathTranslated()
<li>SCRIPT_NAME HttpServletRequest.getServletPath()
<li>QUERY_STRING HttpServletRequest.getQueryString()
<li>REMOTE_HOST HttpServletRequest.getRemoteHost()
<li>REMOTE_ADDR HttpServletRequest.getRemoteAddr()
<li>AUTH_TYPE HttpServletRequest.getAuthType()
<li>REMOTE_USER HttpServletRequest.getRemoteUser()
<li>REMOTE_IDENT ? - but if a server supports RFC 931, it should probably
pass this in getRemoteUser()
<li>CONTENT_TYPE HttpServletRequest.getContentType() For queries which
have attached information, such as HTTP POST and PUT, this is the content
type of the data.
<li>CONTENT_LENGTH HttpServletRequest.getContentLength()
<li>HTTP_ACCEPT HttpServletRequest.getHeader("Accept")
<li>HTTP_USER_AGENT HttpServletRequest.getHeader("User-Agent")
</ul> |
|