title: Getting server address and application name
body: <p>Environment: NetBeans 6.9.1, GlassFish 3.1</p>
  
  <p>I have a Java Web Application. How to get the server address and the application name dynamically? The '2in1' solution would be the best for me: <code>http://localhost:8080/AppName/</code>.</p>
  
  <p>Is there a practical way to get that information?</p>
  
  <p>Let's say the value of <code>AppName</code> will be fixed, so I only need the host address. Is it possible to retrieve it via JMX? Any other ways?</p>