Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Invalid url pattern for filter in web.xml

 
Allen Williams
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to write my first filter. I want it to check all jsp pages (well, as a first pass, anyway). I am getting a bad url-pattern message from tomcat regarding my web.xml file. Here is the mapping:


This app is named smsinfo, and I have also tried:

Is there something really obvious I'm missing? Or, is there more information one needs to figure out why this is getting a bad url error?

The germane error from the traceback in catalina.out is:

at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
Caused by: java.lang.IllegalArgumentException: Invalid <url-pattern> /*.jsp in filter mapping
at org.apache.catalina.core.StandardContext.addFilterMap(StandardContext.java:2078)
... 35 more
Oct 15, 2006 4:15:21 PM org.apache.catalina.startup.ContextConfig applicationWebConfig
SEVERE: Parse error in application web.xml file at jndi:/localhost/smsinfo/WEB-INF/web.xml
java.lang.IllegalArgumentException: Invalid <url-pattern> /*.jsp in filter mapping
at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2725)


Thanks!
 
Stefan Evans
Bartender
Posts: 1777
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Refer to Section 11.2 of the Servlet Specification

In the web application deployment descriptor, the following syntax is used to define
mappings:
� A string beginning with a �/� character and ending with a �/*� postfix 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.

Try it without the initial /
ie: <url-pattern>*.jsp</url-pattern>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic