Java Mailing List Archive

http://www.junlu.com/

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

Re: Trailing slash added

Rashmi Rubdi

2007-01-14

Replies:

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)

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