Getting your server name can be a tricky question because tomcat may be on box1 behind box2. What you probably care about is how the client addressed you, i.e. box1. That information should be included in the HOST header of the request. Here's the output of various HttpServletRequest functions when the browser asked for www.external.com who was apache and who proxied the request to www.internal.com (which is unresolvable to the browser).
value in browser url box: https://www.external.com/hello/world actual resource served: https://www.internal.com/hello/world HttpServletRequest.getRequestURI() = /hello/world HttpServletRequest.getRequestURL() = https://www.external.com/hello/world HttpServletRequest.getServerName() = www.external.com HttpServletRequest.getHeader("HOST") = www.external.com HttpServletRequest.getLocalName() = www.external.com
From HttpUtils.getRequestURL (which I believe is what is actually called by HttpServletRequest.getRequestURL) you can see that host part of getRequestURL is just the result of getServerName. The implementation of getServerName is totally opaque to me but one would hope it was a getHeader("HOST") followed by some system call when absent. According to spec it is the value of the part before ":" in the Host header value, if any, or the resolved server name, or the server IP address.