getRemoteAddrpublic String getRemoteAddr() Returns the Internet Protocol (IP) address of the client or last proxy that sent the request. For HTTP servlets, same as the value of the CGI variable REMOTE_ADDR. Returns:
a String containing the IP address of the client that sent the request
Returns the Internet Protocol (IP) address of the client that sent the request. For HTTP servlets, same as the value of the CGI variable REMOTE_ADDR.Returns:a String containing the IP address of the client that sent the request----------------------------------------------------------------------上面是从JSDK2.3 API文档里拷贝的。
举个例子:
remoteaddr.jsp
...
<%
Stting ip = request.getRemoteAddr();
%>
...如果要写bean的话,就:
import javax.servlet.http.HttpServletRequest;
...
//method
public String getIP(HttpServletRequest req) throws Exception
{
String ip;
ip = req.getRemoteAddr();
return ip;
}
...我也初学者,很多东西也不太懂。如果说的不对,请直接指出来。