You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Rashmi Rubdi <de...@yahoo.com> on 2007/01/15 20:15:20 UTC

[OT] Trailing slash added

----- Original Message ----
From: Len Popp <le...@gmail.com>
To: Tomcat Users List <us...@tomcat.apache.org>
Sent: Monday, January 15, 2007 12:06:09 PM
Subject: Re: Trailing slash added


>>If you move a file you will have to fix some links, no matter what
>>sort of URLs you use. If nothing else, the links that referred to the
>>moved file will be broken. 

Yes

>>But regardless, there are many web sites
>>that do use relative URLs, and that would be a problem in this case.

Yes, there's nothing wrong with using relative URLs. But using context relative URLs minimizes 
the amount of changes that need to be made to the *file that contains them*, as opposed to just relative URLs mentioned inside a file.

Consider index.jsp with this directory structure:

/folder1/folder2/index.jsp

And the code in index.jsp with relative URLs

<a href="../../page1.jsp">Link Text</a>
<a href="page2.jsp">Page 2</a>

If index.jsp is moved from /folder1/folder2/index.jsp  , to /folder1/index.jsp then because there are relative URLs inside index.jsp, they need to be changed as follows:

<a href="../page1.jsp">Link Text</a>
<a href="folder2/page2.jsp">Page 2</a>

But, if all URLs inside index.jsp were context relative as follows:

<a href="/page1.jsp">Link Text</a>
<a href="/folder1/folder2/page2.jsp">Page 2</a>

Then, no matter how many times you move index.jsp the code inside index.jsp that refers to context relative URLs won't change. The amount of code that needs to change appears small in this case but it can save a lot of work, typing and debugging (if the IDE doesn't take care of the changes) on larger projects.

But whatever code is refering to index.jsp itself will have to change - that's unavoidable - but at least you've minimized amount of code that needs to be changed *inside index.jsp itself*. 


>>It doesn't matter if it's done by URLRewriteFilter or some other
>>method because it's the browser that interprets the relative URLs, not
>>the server. If the containing page's URL looks like a file when it's
>>really a directory, the browser will get them wrong. That's why the
>>usual behaviour for servers is to use a re-direct to add "/" or
>>"/index.html" or something. The only other correct response to a
>>"bare" directory name would be to return an error, which is
>>inconvenient for users.

I don't really understand why one would want to get rid of the trailing slash.

-Rashmi


 
____________________________________________________________________________________
Want to start your own business?
Learn how on Yahoo! Small Business.
http://smallbusiness.yahoo.com/r-index

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org