Tomcat 5.0 web.xml filter mapping <url-pattern>/content/*.jsp - Java

This is a discussion on Tomcat 5.0 web.xml filter mapping <url-pattern>/content/*.jsp - Java ; I am having problem using filter mapping in in Tomcat 5.0 on windows I tried the following in my web.xml. .... &lt;filter-mapping&gt; &lt;filter-name&gt;foo.bar.MyFilter&lt;/filter-name&gt; &lt;url-pattern&gt;/content/*.jsp&lt;/url-pattern&gt; &lt;/filter-mapping&gt; .... When I start Tomcat it tells me: SEVERE: Parse error in application web.xml java.lang.IllegalArgumentException: ...

+ Reply to Thread
Results 1 to 3 of 3

Tomcat 5.0 web.xml filter mapping <url-pattern>/content/*.jsp

  1. Default Tomcat 5.0 web.xml filter mapping <url-pattern>/content/*.jsp

    I am having problem using filter mapping in in Tomcat 5.0 on windows
    I tried the following in my web.xml.
    ....
    <filter-mapping>
    <filter-name>foo.bar.MyFilter</filter-name>
    <url-pattern>/content/*.jsp</url-pattern>
    </filter-mapping>
    ....
    When I start Tomcat it tells me:
    SEVERE: Parse error in application web.xml
    java.lang.IllegalArgumentException: Invalid <url-pattern> /content/*.jsp in
    filter mapping
    at org.apache.commons.digester.Digester.createSAXException(Digester.java:2540)
    at org.apache.commons.digester.Digester.createSAXException(Digester.java:2566)
    at org.apache.commons.digester.Digester.endElement(Digester.java:1061)
    ....

    It doesn't do it in a friends Tomcat 4.1 on Linux
    Is this some kind of change in behavior from Tomcat 4.0 to 5.0?
    (Tomcat 5.0 is Servlet API 2.4 and JSP 2.0)

    The idea is that I want it to run my this filter before all JSP pages, but
    not with all .jpg, .gif requests that come in, even if they are within
    the some directory structure.

    Seems simple enough in the example from a friends Tomcat 4.0

    -Paul


  2. Default Re: Tomcat 5.0 web.xml filter mapping <url-pattern>/content/*.jsp

    P.Hill wrote:
    > <filter-mapping>
    > <filter-name>foo.bar.MyFilter</filter-name>
    > <url-pattern>/content/*.jsp</url-pattern>
    > </filter-mapping>


    Upon further reading, I have discovered that my
    friend can't be trusted. *.jsp doesn't work in
    4.1, and it complains as I reported in 5.0.

    My solution at this time is to allow requests
    for things other than jsps through the same
    filter to skip the filtering, since the filter
    doesn't need to kick in just because someone
    is asking for background.jpg or some such.

    Yeah, I know we might consider rearranging the
    dir structure to put jsps separate from content,
    but that doesn't seem like a useful step at this
    time.

    Other ideas?

    -Paul


  3. Default Re: Tomcat 5.0 web.xml filter mapping <url-pattern>/content/*.jsp

    We had the same problem with a jsp-property-group url-pattern, and I did
    some searches on google on this topic (that's how I ended up in here for
    example)

    Most clear result I found was:

    http://www.mail-archive.com/tomcat-d.../msg43676.html

    Where it says that mapping /somepath/*.something worked in a version of
    tomcat, but is removed since it does not comply with the Servlet
    specification.

    This is what the servlet specification (2.4) allows:

    - 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.


    So what you (and we) are trying to do, cannot be done according to the
    Servlet 2.4 specification.


+ Reply to Thread

Similar Threads

  1. Novice Tomcat design pattern question
    By Application Development in forum Java
    Replies: 9
    Last Post: 12-03-2007, 12:07 PM
  2. Re: Setting a response header in a Tomcat Filter
    By Application Development in forum Java
    Replies: 3
    Last Post: 08-29-2007, 09:56 AM
  3. Tomcat servlet-mapping question
    By Application Development in forum Java
    Replies: 0
    Last Post: 07-17-2007, 06:29 PM
  4. Content Filter - Mercury32
    By Application Development in forum Pegasus
    Replies: 2
    Last Post: 10-17-2006, 03:47 PM
  5. filter pattern question
    By Application Development in forum Pine
    Replies: 2
    Last Post: 10-14-2005, 07:55 AM