You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Ramesh Mandava <rm...@yahoo.com> on 2000/09/08 00:02:17 UTC

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

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
 
 Similary if we have a HTML form in the html page
under some context root and mention relative path to
another JSP in the same application it won't work
unless we mention the /contextroot/<jspname> , which
will force us to fix the context root. this will cause
problem even when we try to integrate Tomcat code into
J2EE where we can dynamically decide the Conext Root.
Tomcat 3.X works fine by using contextpath when we
just give relative path. 

Thanks
 -Ramesh.Mandava 


__________________________________________________
Do You Yahoo!?
Yahoo! Mail - Free email you can access from anywhere!
http://mail.yahoo.com/

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

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
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