title: How to get only part of URL from HttpServletRequest?
body: <p>From the following URL I need to get <code>(http://localhost:9090/dts)</code> alone.<br>
  That is I need to remove <code>(documents/savedoc)</code> (OR)<br>
     need to get only - <code>(http://localhost:9090/dts)</code></p>
  
  <pre><code>http://localhost:9090/dts/documents/savedoc  
  </code></pre>
  
  <p>Is there any method available in request to get the above?</p>
  
  <p>I tried the following and got the result. But still trying.  </p>
  
  <pre><code>System.out.println("URL****************"+request.getRequestURL().toString());  
  System.out.println("URI****************"+request.getRequestURI().toString());
  System.out.println("ContextPath****************"+request.getContextPath().toString());
  
  URL****************http://localhost:9090/dts/documents/savedoc  
  URI****************/dts/documents/savedoc  
  ContextPath****************/dts
  </code></pre>
  
  <p>Can anyone please help me in fixing this?</p>