webtier@glassfish.java.net

Re: [webtier] aligned url-pattern in web.xml

From: Dies Koper <diesk_at_fast.au.fujitsu.com>
Date: Wed, 22 Apr 2009 11:54:08 +1000

Hi Jan,

I can do that.

Just to make sure we agree what the patch will do:

1. First it will try to make a url without trimming (as the spec
explicitly says), as is done now.
2. If creation of the url failed, trim it, try again.
3. If the url could not be parsed after trimming, throw original error
(discard exception at 2).
4. If the url was successfully parsed, use it, but log a warning any way
(again, as the spec seems to explicitly mention it).

I can also implement 4 to only log a warning if the text included a
CR(#xD) or LF(#xA), to really follow the spec to the letter.

Regards,
Dies


Jan Luehe wrote:
> Hi Dies,
>
> On 04/21/09 04:59 PM, Dies Koper wrote:
>> Hi Jan,
>>
>> I have a servlet application with a few spaces in the url-pattern, which
>> deploys fine on Tomcat, not on GF.
>>
>> <web-app>
>> <servlet>
>> <servlet-name>
>> AA
>> </servlet-name>
>> <jsp-file>
>> /aa.jsp
>> </jsp-file>
>> </servlet>
>> <servlet-mapping>
>> <servlet-name>
>> AA
>> </servlet-name>
>> <url-pattern>
>> /*
>> </url-pattern>
>> </servlet-mapping>
>> </web-app>
>>
>> Deployment (in GFv3-ea-b42) failed with the following message.
>>
>> message: Exception while deploying the app : java.lang.IllegalArgument
>> Exception: Invalid URL Pattern: [
>> /*
>> ]
>> use-main-children-attribute: false
>>
>> Changing the url-pattern to <url-pattern>/*</url-pattern> fixes the
>> error.
>> The Servlet spec says:
>>
>> URI paths specified in the deployment descriptor are assumed to be in
>> URL decoded form. The containers must inform the developer with a
>> descriptive error message when URL contains CR(#xD) or LF(#xA). The
>> containers must preserve all other characters including whitespace in
>> URL.
>>
>> Why is it so strict?
>> Can't it just catch the exception, do a trim() and try again?
>>
>
> Yes, that might be a good idea!
>
> I've seen this problem a few times as people were trying to migrate from
> Tomcat to GlassFish.
>
> Let me know if you'd be interested in working on a patch for this.
>
> Thanks!
>
> Jan
>
>> Thanks,
>> Dies