本文整理汇总了Java中javax.servlet.ServletRequest.getRemoteHost方法的典型用法代码示例。如果您正苦于以下问题:Java ServletRequest.getRemoteHost方法的具体用法?Java ServletRequest.getRemoteHost怎么用?Java ServletRequest.getRemoteHost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.servlet.ServletRequest
的用法示例。
在下文中一共展示了ServletRequest.getRemoteHost方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveHost
import javax.servlet.ServletRequest; //导入方法依赖的package包/类
public String resolveHost() {
String host = getHost();
if (host == null) {
//check to see if there is an AuthenticationToken from which to retrieve it:
/*
AuthenticationToken token = getAuthenticationToken();
if (token instanceof HostAuthenticationToken) {
host = ((HostAuthenticationToken) token).getHost();
}
*/
}
if (host == null) {
Session session = resolveSession();
if (session != null) {
host = session.getHost();
}
}
if (host == null) {
ServletRequest request = resolveServletRequest();
if (request != null) {
host = request.getRemoteHost();
}
}
return host;
}
示例2: getHost
import javax.servlet.ServletRequest; //导入方法依赖的package包/类
/**
* Returns the host name or IP associated with the current subject. This method is primarily provided for use
* during construction of an <code>AuthenticationToken</code>.
* <p/>
* The default implementation merely returns {@link ServletRequest#getRemoteHost()}.
*
* @param request the incoming ServletRequest
* @return the <code>InetAddress</code> to associate with the login attempt.
*/
protected String getHost(ServletRequest request) {
return request.getRemoteHost();
}