webtier@glassfish.java.net

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

From: Jan Luehe <Jan.Luehe_at_Sun.COM>
Date: Tue, 28 Apr 2009 20:29:57 -0700

Hi Dies,

On 04/26/09 11:45 PM, Dies Koper wrote:
> Hi Jan, Hong,
>
> Could you review my patch (attached to issue 7976)?
> https://glassfish.dev.java.net/issues/show_bug.cgi?id=7976

Looks great!! Thanks for this patch!
>
> If the url-pattern is aligned as follows, the resulting message will be:
> <url-pattern>
> /TPS
> </url-pattern>
>
> [#|2009-04-24T14:18:33.765+1000|WARNING|glassfish|javax.enterprise.system.tools.deployment.org.glassfish.deployment.common|_ThreadID=19;_ThreadName=Thread-1;
>
> /TPS
> ;|"DPL8023: URL Pattern contains CR(#xD) or LF(#xA): [
> /TPS
> ]. Leading and trailing whitespace will be ignored."|#]
>
> The only ugly bit about it is that the thread name(?) seems to include
> the url pattern too. It would be nicer if it would use the trimmed
> name, but I'm not sure where it gets set and how to chance it.
>
> Any suggestions?

Not sure. The thread name seems to be equal to "Thread-1" in your
example, and the remainder
of the line seems to be the warning message you wanted logged. I don't
see anything wrong with
that.


Jan


> Regards,
> Dies
>
>
> Jan Luehe wrote:
>> Hi Dies,
>>
>> On 04/21/09 06:54 PM, Dies Koper wrote:
>>> Hi Jan,
>>>
>>> I can do that.
>> Great!
>>>
>>> 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.
>>
>> Sounds good!
>>
>> Jan
>>
>>>
>>> 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
>
>