You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ken Bowen <kb...@als.com> on 2007/10/09 15:37:17 UTC

Question about renaming myapp.war to ROOT.war

Hi All,

Renaming myapp.war to ROOT.war (as recommended) in order to make myapp 
the default application has worked fine.
However, I've seen one bit of odd behavior as follows.  If request is 
the incoming HttpServletRequest, then:

--  when the app is running from webapps/myapp,  one gets 
request.getContextPath() = "/myapp"

--  when the app is running from webapps/ROOT,  the value of 
request.getContextPath() is the empty string.

It's almost as if the value of request.getContextPath() is the value of 
the Context 'path' attribute when the Context was stored under Host in 
the old way.

Is this essentially correct, or am I missing something here?

Thanks in advance,

Ken Bowen

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


Re: Question about renaming myapp.war to ROOT.war

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ken,

Ken Bowen wrote:
> --  when the app is running from webapps/myapp,  one gets
> request.getContextPath() = "/myapp"
> 
> --  when the app is running from webapps/ROOT,  the value of
> request.getContextPath() is the empty string.

This is expected behavior.

> It's almost as if the value of request.getContextPath() is the value of
> the Context 'path' attribute when the Context was stored under Host in
> the old way.

Yep, pretty much.

The idea is that you can do something like:

request.getContextPath() + "/bar/baz" and always get an absolute URI. If
your context name is "foo", then you get "/foo/bar/baz". If you are
running the root web app, you get "/bar/baz", which is expected (rather
than, say, "//bar/baz").

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHC4sp9CaO5/Lv0PARApsTAJ4zeqq4M8LKMlVjrVj4ktxfxGBHbQCfQ9F2
efwFhRna9vTi/0p6W0e0ED0=
=+aYX
-----END PGP SIGNATURE-----

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