Unable to get remote IP address and location on lifelong passages

I use ubuntu 12.04, liferay version 6.0.1, open jdk 6 on my system. I tried to get remote ip and location in java. To do this, I found Host Ip , with which we can get the apache http get method. I successfully executed this on my local system. But in fact, the liferay portlet is not running, and it is difficult to find an error, since several instances work simultaneously. The server is based on Windows. I use this method in doView () of the MVC portlet to get ip

com.liferay.portal.util.PortalUtil.getHttpServletRequest(renderRequest).getRemoteAddr()
+5
source share
2 answers

When I will not access the http header information, I use:

HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(portletRequest);
HttpServletRequest originalServletRequest = PortalUtil.getOriginalServletRequest(httpServletRequest);
originalServletRequest.getRemoteAddr();

httpServletRequest, ServletRequest

+1

. , . ,

MyIP Portlet Liferay Marketplace - , IP- RenderRequest PortletRequest.

github: IPAddressUtil.java

0

All Articles