You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Phil Radden <ph...@frogtop.com> on 2000/11/20 15:49:45 UTC

Serving welcome page v. issuing HTTP redirect

There appears to be a change of behaviour between Tomcat 3.1 and 3.2bX
regarding the handling of the top page for a servlet.

I have a servlet in ROOT context, and wish a particular file, say index.jsp,
to be used for requests for 'GET / HTTP/1.0'.  In 3.1, this is what happens.
In 3.2, an HTTP redirect to 'Location: /index.jsp' is issued instead.

Ideally, I'd want the 3.1 behaviour.  And failing that, the redirection
should really be to a fully-qualified URL.  Any suggestions on what I should
try?

Many thanks


Re: Serving welcome page v. issuing HTTP redirect

Posted by Phil Radden <ph...@evtechnology.com>.
On Mon, 20 Nov 2000, Craig R. McClanahan wrote:
> The redirect should be setting an absolute URL in the "Location:" header -- if
> it's not, that is a Tomcat bug, because the container is required to create an
> absolute URL even if the program specifies a relative one.  I will look into it.

Many thanks Craig - and there's no need to investigate, because it appears I
was confused.  Tomcat 3.2 does the right thing (in my testing at least) -
the system that wasn't was using another platform which had better remain
anonymous!

Apologies, and thanks for the swift explanation


Re: Serving welcome page v. issuing HTTP redirect

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Phil Radden wrote:

> There appears to be a change of behaviour between Tomcat 3.1 and 3.2bX
> regarding the handling of the top page for a servlet.
>
> I have a servlet in ROOT context, and wish a particular file, say index.jsp,
> to be used for requests for 'GET / HTTP/1.0'.  In 3.1, this is what happens.
> In 3.2, an HTTP redirect to 'Location: /index.jsp' is issued instead.
>
> Ideally, I'd want the 3.1 behaviour.  And failing that, the redirection
> should really be to a fully-qualified URL.  Any suggestions on what I should
> try?
>

What's going on is Tomcat is redirecting to the welcome page you have configured
for this directory.  The redirect is important because a welcome file can have
relative hyperlinks, and they are resolved to the wrong place under several
different usage cases.

The redirect should be setting an absolute URL in the "Location:" header -- if
it's not, that is a Tomcat bug, because the container is required to create an
absolute URL even if the program specifies a relative one.  I will look into it.

> Many thanks

Craig McClanahan