views:

9742

answers:

3
print("<pre><code><servlet>  <servlet-name>myservlet</servlet-name>  <servlet-class>workflow.WDispatcher</servlet-class>  <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping>  <servlet-name>myservlet</servlet-name> <url-pattern>*NEXTEVENT*</url-pattern></servlet-mapping></code></pre>");

Above is the snippet form tomcat's web.xml, the url pattern is NEXTEVENT on start up creates java.lang.IllegalArgumentException.It will be greatly appreciated if some can hint at the error. Thanks

+11  A: 
<url-pattern>*NEXTEVENT*</url-pattern>

The URL pattern is not valid. It can either end in an asterisk or start with one (to denote a file extension mapping).

The url-pattern specification:

  • A string beginning with a ‘/’ character and ending with a ‘/*’ suffix is used for path mapping.
  • A string beginning with a ‘*.’ prefix is used as an extension mapping.
  • A string containing only the ’/’ character indicates the "default" servlet of the application. In this case the servlet path is the request URI minus the context path and the path info is null.
  • All other strings are used for exact matches only.

See SRV.11.2 of the Java Servlet Specification Version 2.4 for more details.

McDowell
A: 

A workaround that can achieve that is to add a servlet filter to do URL re-writes e.g. re-write NEXTEVENT to /NEXTEVENT/(the one before the NEXTEVENT)/(the one after NEXTEVENT) or something similar.

talg
+4  A: 

This reference provides a good summary of what can and what cannot go in a url-pattern.

wrumsby