Available categories: [/] [working on downwap.] [trouble shooting] [working on Yup Mailman]
Get Ip Addr. From The HttpServletRequest Wrapped By The "iisforward" ISAPI Extension In Weblogic | 通过iisforward isapi ext访问weblogic的取ip问题 [Permalink] Sun Oct 02 12:46:42 CST 2005 在IIS+Weblogic整合系统中,像移动网关一样,iisforward这个ISAPI过滤器也会对request对象进行再包装,附加一些WLS要用的头信息。这种情况下,直接用 WL-Proxy-Client-IP=211.161.1.239 Proxy-Client-IP=211.161.1.239 X-Forwarded-For=211.161.1.239 WL-Proxy-Client-Keysize= WL-Proxy-Client-Secretkeysize= X-WebLogic-Request-ClusterInfo=true X-WebLogic-KeepAliveSecs=30 X-WebLogic-Force-JVMID=-327089098 WL-Proxy-SSL=false综上,正确作法如下: public String getIpAddr(HttpServletRequest request) { String ip=request.getHeader("X-Forwarded-For"); if(ip == null || ip.length() == 0) { ip=request.getHeader("Proxy-Client-IP"); } if(ip == null || ip.length() == 0) { ip=request.getHeader("WL-Proxy-Client-IP"); } if(ip == null || ip.length() == 0) { ip=request.getRemoteAddr(); } return ip; }如此一来,就可适应各种情况,包括通过移动网关访问(会附加X-Forwarded-For)。通过这个简单例子可以看出封装和抽象的重要性。
Posted by: miles |
? |
Available categories: [/] [working on downwap.] [trouble shooting] [working on Yup Mailman]
html hits:?23576