StringBuffer requestURL = request.getRequestURL(); URI ip = IpUtil.getIP(new URI(requestURL.toString()));
public class IpUtil { public static URI getIP(URI uri) { URI effectiveURI = null; try { // URI(String scheme, String userInfo, String host, int port, String // path, String query,String fragment) effectiveURI = new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), null, null, null); } catch (Throwable var4) { effectiveURI = null; } return effectiveURI; } }