webtier@glassfish.java.net

aligned url-pattern in web.xml

From: Dies Koper <diesk_at_fast.au.fujitsu.com>
Date: Wed, 22 Apr 2009 09:59:07 +1000

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?

Thanks,
Dies