Is there an easy way to get the clients IP address?

0
"How to get the computer name (can be replaced by IP address)? When updating Entity in Mendix, I want Entity to retain the terminal information "computer name" that I entered. Is there any way to get the "computer name" (or IP address) in Mendix?"
asked
2 answers
3

the community commons module has an useful Java action GetIP

https://marketplace.mendix.com/link/component/170 

answered
2

In a custom java action


	// BEGIN EXTRA CODE
	private String getClientIp() {
		IContext ctx = getContext();
		Optional<IMxRuntimeRequest> orr = ctx.getRuntimeRequest();
		String realIP = null;
		if (orr.isPresent()) {
		    IMxRuntimeRequest rr = orr.get();
		    HttpServletRequest request = rr.getHttpServletRequest();
		    realIP = rr.getHeader("X-Real-IP");
		    if( realIP == null )
		        realIP = rr.getHeader("X-Forwarded-For");
		    if( realIP == null )
		        realIP = rr.getRemoteAddr();
		}
		return realIP;
	}
	// END EXTRA CODE

I think I copied this from some other question on this forum.

answered