title: How can I get the name of the current web app in Java EE?
body: <p>How can I get the name of the current web app in Java EE?</p>
  
  <p>I'm quite comfortable with stand-alone Java, but Java EE is new to me. I'm writing some custom code to plug in to a third-party Java EE reporting package. I have multiple instances deployed on the same Tomcat server, so I have something like:</p>
  
  <pre>
  C:\
  +-- tomcat6
      +-- webapps
          +-- app1
          +-- app2
  </pre>
  
  <p>So when the user goes to, let's say, <a href="http://example.com/app1/viewReport" rel="noreferrer">http://example.com/app1/viewReport</a>, I want to be able to get "app1". (And not by parsing the URL, preferrably.)</p>
  
  <p>Also, if there was a way to get the root of app1 (in this example, C:\tomcat6\webapps\app1), that would be great too.</p>