Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Apache Tomcat »

Re: Trailing slash added

Len Popp

2007-01-15

Replies:

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. But regardless, there are many web sites
that do use relative URLs, and that would be a problem in this case.

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.
--
Len

On 1/14/07, Rashmi Rubdi <dev_subscriptions@(protected):
> Instead of relative URLs, it's better to use context relative URLs.
>
> With context relative URLs if the page containing the context relative links is moved to a different folder the code won't have to change. Context relative URLs always begin with / and start from the root folder of your app, for example /root_folder/somefile.jsp
>
> But, if you use relative URLs then every time you move your file to a different folder the URLs in that file will also have to change depending on the depth of the new folder.
> Relative URLs never begin with a / , and they look something like somefolder/somefile.jsp, or ../somefolder/somefile.jsp
>
> I haven't tested the effect of URL Rewriting on the trailing slash on context relative URLs.
>
> But with URL Rewriting may of Apache's features, become available on Tomcat as well. For example you can rewrite http://www.domainname.com to http://domainname.com
>
> -Rashmi
>
> ----- Original Message ----
> From: Len Popp <len.popp@(protected)>
> To: Tomcat Users List <users@(protected)>
> Sent: Sunday, January 14, 2007 7:41:03 PM
> Subject: Re: Trailing slash added
>
>
> Note that if you allow the browser to refer to directories without the
> trailing slash, you will break the handling of relative URLs on those
> pages. When the user clicks on a link with a relative URL, the browser
> has to convert that to an absolute URL. If the browser doesn't know
> that the current page is a directory it will calculate the absolute
> URL incorrectly.
> --
> Len
>
> On 1/14/07, Rashmi Rubdi <dev_subscriptions@(protected):
> > I think you can customize it with URL Rewriting Filters.
> >
> > Google URLRewriteFilter to find pre-built packages, or you can write your own.
> >
> > -Rashmi
> >
> > ----- Original Message ----
> > From: Tim Funk <funkman@(protected)>
> > To: Tomcat Users List <users@(protected)>
> > Sent: Sunday, January 14, 2007 12:26:39 PM
> > Subject: Re: Trailing slash added
> >
> >
> > There is no way to customize this behavior other than overriding the
> > default servlet with your own implementation.
> >
> > -Tim
> >
> > lightbulb432 wrote:
> > > I noticed that Tomcat adds a trailing slash automatically when it detects
> > > that the requested resource points to an existing directory. While I know
> > > that Apache web server offers plenty of configuration options to control and
> > > customize this behavior, I'm unfamiliar with similar customization
> > > capability within Tomcat. (Where is this trailing slash behavior specified
> > > for Tomcat? Or is it a compiled-in setting function that cannot be changed?)
> > >
> > > How can I customize this and other Apache-like settings? Is the only option
> > > to front Tomcat with Apache?
> >
>
>
>
> ____________________________________________________________________________________
> Sucker-punch spam with award-winning protection.
> Try the free Yahoo! Mail Beta.
> http://advision.webevents.yahoo.com/mailbeta/features_spam.html
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@(protected)
> To unsubscribe, e-mail: users-unsubscribe@(protected)
> For additional commands, e-mail: users-help@(protected)
>
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@(protected)
To unsubscribe, e-mail: users-unsubscribe@(protected)
For additional commands, e-mail: users-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.