title: How to get browser URL in Apache-Tomcat Web Application?
body: <p>I have configured my web application using Apache-Tomcat connector through mod_proxy - see below.</p>
  
  <pre><code>&lt;IfModule mod_proxy.c&gt;
  ProxyPass /myapp http://127.0.0.1:8080/myapp
  ProxyPassReverse /myapp http://127.0.0.1:8080/myapp
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>Also, I am using sub-domains in order to identify the clients directly by reading the URL - see below for the example.</p>
  
  <p>Client1 types</p>
  
  <pre><code>http://client1.mydomain.com/myapp
  </code></pre>
  
  <p>Client2 types</p>
  
  <pre><code>http://client2.mydomain.com/myapp
  </code></pre>
  
  <p>Now, I want to read the URL and parse the client name (client1 or client2). The rest of my web application is driven based on who the client is (of course, after authentication). But the issue is, when I try to get URL using HttpServletRequest's getRequestURL, I get <a href="http://127.0.0.1:8080/myapp" rel="nofollow">http://127.0.0.1:8080/myapp</a> instead of client1.mydomain or client2.mydomain. This, I suppose, is due to Apache being used as the primary dispatcher and the request to Apache httpd is being forwarded to localhost Tomcat.</p>
  
  <p>I don't want to change the structure of URL (like client1.mydomain.com/client1) nor do I want to ask user for the client information through UI. How do I achieve this?</p>