How to get the URL basename and IP address of current serlet context?
For example, if my website is "www.non-existent.website.com", and Tomcat is running on this website, then how can I get the website name? Preferrably I'd like to get it from the ServletContextEvent. What I want to do is this:
class MyListener implements ServletContextListener {
public void contextInitialized(ServletContextEvent sce) {
if (sce.getServletContext().getDomain().equals("www.non-existent.website.com"))
setLoggerLevel(Level.WARN);
else
setLoggerLevel(Level.DEBUG);
}
}
So when running the app server on a debug machine, I want to set the log level to DEBUG, otherwise to WARN. The DEBUG machine has the URL basename as "localhost".
Getting the IP address is a related question. But on a complex load balanced system, the IP address could change with each request.
Thanks.