title: How to get application context in Rails
body: <p>I have a URL like <code>http://myapp.myorg.com/MyApp/one/two</code> and I want to extract the first part myapp.myorg.com/MyApp/ in the Rails code. Please help me in getting this URL correct.</p>
  
  <p>I'm currently using $servlet_context for this purpose, but it does not give me the result.</p>
  
  <p>My code snippet:</p>
  
  <p><code>&lt;%= link_to "My Link", "{@hostname}/#{$servlet_context}/three/four" %&gt;</code>.</p>
  
  <p>This gives me a URL like:</p>
  
  <pre><code>myapp/org.jruby.rack.servlet.ServletRackContext@622209db/three/four
  </code></pre>
  
  <p>I'm expecting something like:</p>
  
  <pre><code>myapp/MyApp/three/four
  </code></pre>