<p>The subject says it all, almost. How do I automatically fix jsp pages so that relative URLs are mapped to the context path instead of the server root? That is, given for example</p>

<pre><code>&lt;link rel="stylesheet" type="text/css" href="/css/style.css" /&gt;
</code></pre>

<p>how do I set-up things in a way that maps the css to <code>my-server/my-context/css/style.css</code> instead of <code>my-server/css/style.css</code>? Is there an automatic way of doing that, other than changing all lines like the above to</p>

<pre><code>&lt;link rel="stylesheet" type="text/css" 
      href="&lt;%= request.getContextPath() %&gt;/css/style.css" /&gt;
</code></pre>

Look into the
```
<BASE HREF="">
```
tag. This is an HTML tag which will mean all links on the page should start with your base URL.
For example, if you specified
```
<BASE HREF="http://www.example.com/prefix">
```
and then had
```
<a href="/link/1.html">
```
then the link should actually take you to /prefix/link/1.html. This should also work on
```
<LINK>
```
(stylesheet) tags.