title: basepath in jsp
body: <p>In my application,I use the struts2,and I create a base action to slove the path problem:</p>
  
  <pre><code>class BaseAction{
    private String path;
    static{
    HttpServletRequest request = ServletActionContext.getRequest(); path=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath();+"/";
    }
  }
  </code></pre>
  
  <p>Then all other action extend this baseaction.</p>
  
  <p>In my jsp page,I add the path as the base:</p>
  
  <p>xx.jsp:</p>
  
  <pre><code>....
  &lt;head&gt;
    &lt;base href="&lt;s:property value='path'/&gt;"&gt;
    &lt;script ... src="res/test.js" /&gt;
  &lt;/head&gt;
  </code></pre>
  
  <p>It works well in my own machine.</p>
  
  <p><a href="http://localhost:8080/app" rel="nofollow">http://localhost:8080/app</a>
  The test.js canbe found by "http://localhost:8080/app/res/test.js"</p>
  
  <p>But when other people try to visit my app,they use:</p>
  
  <p><a href="http://192.168.x.x:8080/app" rel="nofollow">http://192.168.x.x:8080/app</a>.</p>
  
  <p>now,the browser still try to download the test.js by 
  "http://localhost:8080/app/res/test.js"</p>
  
  <p>Of course,it can not get it. The real path should be:
  <a href="http://192.168.x.x:8080/app/res/test.js" rel="nofollow">http://192.168.x.x:8080/app/res/test.js</a></p>
  
  <p>SInce, the "path" is hard code in teh action,any idea to fix this?</p>