You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by "Craig R. McClanahan" <Cr...@eng.sun.com> on 2000/09/08 00:32:37 UTC

Re: [BUG]:Relative path is always taken from the server root?

Ramesh Mandava wrote:

> Hi:
>
>   SETUP: TMCAT4.0 ( Catalina 2000/09/05 nightly)
>   PLATFORM : ALL
>
>    If we have any index.html under some Context root(
> eg.JSP11ActPosTests ) and have relative links like
> test1.jsp they are expanded as
>
> http://servername:port/test1.jsp
>
> instead of
> http:/<servername>:<port>/<contextroot>/test1.jsp
>

Ramesh,

When you say "relative" link, how are they being expressed?  Your bug
report doesn't give me a precise example of what you are talking about,
so I'm going to describe what I think you're talking about.

Let's assume that you are in a webapp whose context path is "/myapp", and
we are talking about the page at URL

    http://localhost:8080/myapp/index.jsp

and want to link to menu.jsp in the same web app.

If you use a hyperlink like this:

    <a href="menu.jsp">Menu</a>

It will go to the "menu.jsp" page in the same web application -- it goes
to:

    http://localhost:8080/myapp/menu.jsp

However, if you create your hyperlink like this:

    <a href="/menu.jsp">Menu</a>

this link is interpreted by the *browser* as

    http://localhost:8080/menu.jsp

because the browser assumes that "/" based paths are resolved from the
server root, not the directory containing the current page.  Note that
the server has nothing at all to do with this.

If this is not what you are seeing, could you please give me a small
actual example (so I can reproduce it) that works in Tomcat 3.x but not
in 4.0?

Craig McClanahan

====================
See you at ApacheCon Europe <http://www.apachecon.com>!
Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
                                    Applications to Tomcat