[ACCEPTED]-Getting server address and application name-jmx
Accepted answer
The HttpServletRequest
object will give you what you need:
HttpServletRequest#getLocalAddr()
: The server's IP address as a stringHttpServletRequest#getLocalName()
: The name of the server receiving the requestHttpServletRequest#getServerName()
: The name of the server that the request was sent toHtppServletRequest#getLocalPort()
: The port the server received the request onHttpServletRequest#getServerPort()
: The port the request was sent toHttpServletRequest#getContextPath()
: The part of the path that identifies the application
0
Inside a servlet you can get it like this
public static String getUrl(HttpServletRequest request) {
return request.getRequestURL().toString();
}
0
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.