Russell Freeman wrote:
> To restate a so far unresolved problem,
>
> Do I need to include the name of my context in all hyperlinks, e.g. if my
> context is /foo, then a link will be <a href="/foo/index.html">, my
> stylesheet will be in "/foo/styles.css" etc.
>
If you are creating hyperlinks that start with "/" then you *do* need the
context path added on the front. This is because the browser will interpret
such a URL as being relative to the server's document root.
If you use relative URLs, though (not starting with "/"), then you do *not* want
to add the context path. For example, if you have a page "index.html" that
wants to create a link to a page "display.html" in the same directory, simply
write:
<a href="display.html">The Display Page</a>
>
> So far things only work if I add the context prefix but not for
> sendRedirect(), which seems to not need it?
>
response.sendRedirect() converts relative URLs back to absolute ones (adding the
content path for you). This behavior is required by the servlet specification,
although not every servlet container actually does it.
>
> Confused,
> Russ
Craig McClanahan