Hmm we should be handling this outside of the default servlet though. Check out this
specific example in 10.10
"A request URI of /catalog/products will be redirected to a URI of
/catalog/products/.
■ A request URI of /catalog/products/ will be passed to the “default” servlet, if
any. If no “default” servlet is mapped, the request may cause a 404 not found,
may cause a directory listing including shop.jsp and register.jsp, or may
cause other behavior defined by the container. See Section 12.2, “Specification of
Mappings” for the definition of “default” servlet."
On Aug 7, 2013, at 10:03 AM, Stuart Douglas <sdouglas(a)redhat.com> wrote:
Yea, that only applies to welcome files though, so this functionality
is provided by the Undertow default Servlet. Gatein replaces the default Servlet though,
which is why the context root needs special case handling.
For other URI's you cannot redirect if default servlet is a custom servlet, simply
because you have no way of knowing which paths that servlet will consider to be
directories.
----- Original Message -----
> From: "Jason Greene" <jgreene(a)redhat.com>
> To: "Stuart Douglas" <sdouglas(a)redhat.com>
> Cc: "Bill Burke" <bburke(a)redhat.com>, undertow-dev(a)lists.jboss.org
> Sent: Wednesday, 7 August, 2013 4:23:27 PM
> Subject: Re: [undertow-dev] undertow is redirecting?
>
> It's not just content root's that need to be redirected, but also all
> subdirectories. Check out the rules in 10.10
>
> On Aug 7, 2013, at 2:36 AM, Stuart Douglas <sdouglas(a)redhat.com> wrote:
>
>>
>> This is an issue that will be fixed once the latest Undertow release is
>> merged into WF core. It came about as a result of fixing
>>
>>
https://issues.jboss.org/browse/UNDERTOW-89
>>
>> With the latest code it only redirects if the target is the war root
>> without a / and the target servlet is registered as the default servlet.
>>
>> I have done a Undertow release with this fix, I just need to sort out some
>> of the development mode stuff before it can be merged into core.
>>
>> Stuart
>>
>>>
>>>
>>> On Aug 6, 2013, at 6:55 PM, Bill Burke <bburke(a)redhat.com> wrote:
>>>
>>>> Client is doing a get request:
>>>>
>>>> GET /jaxrs_spec_resource_requestmatching_web HTTP/1.1
>>>>
>>>>
>>>> Response is is a 302. Notice that there is no trailing / for the path.
>>>> Is this part of tthe servlet spec or something?
>>>
>>> Is this a WAR root or subdirectory (and not a servlet)? if so then yes,
>>> take
>>> a look at section 10.10 of the servlet spec. It just uses the term
>>> "redirect" and in all other places in the spec they refer to 302
with the
>>> word redirect, and never 301.
>>>
>>>
>>>> Did Undertow used to
>>>> send a 301, or just invoke on the war's root?
>>>
>>> I think it used to forward.
>>>
>>>>
>>>> I have a JAX-RS TCK test that is regressing. It is expecting a 200 or
>>>> 301 response back from the server. I need to know how to word the
>>>> challenge to allow 302 as well, or Undertow needs to be fixed.
>>>
>>> I am not sure which makes more sense. 301 would be more efficient but I
>>> can
>>> think of some contrived scenarios where you change the layout of your war
>>> and the client misbehaves.
>>>
>>> e.g you have foo.war/blah/ as a directory but then you later map blah to a
>>> servlet, so then the servlet gets the trailing slash which it somehow
>>> mishandles.
>>>
>>> Hmm. As I say that I am leaning more towards 301.
>>>
>>> IMO the TCK should accept any redirect status code, since it is not
>>> restricted in the spec.
>>>
>>>
>>>>
>>>> Thanks,
>>>>
>>>> Bill
>>>>
>>>> --
>>>> Bill Burke
>>>> JBoss, a division of Red Hat
>>>>
http://bill.burkecentral.com
>>>> _______________________________________________
>>>> undertow-dev mailing list
>>>> undertow-dev(a)lists.jboss.org
>>>>
https://lists.jboss.org/mailman/listinfo/undertow-dev
>>>
>>> _______________________________________________
>>> undertow-dev mailing list
>>> undertow-dev(a)lists.jboss.org
>>>
https://lists.jboss.org/mailman/listinfo/undertow-dev
>>>
>
--
Jason T. Greene
WildFly Lead / JBoss EAP Platform Architect
JBoss, a division of Red Hat