Servlet Mapping with wildcards

Discussion in 'Java' started by Dale, Jan 23, 2004.

  1. Dale

    Dale Guest

    Is there any way in the web.xml, to define the servlet mappings in
    such a way that I want to map all urls, EXCEPT for particular
    patterns.

    Here is my problem.... I want to ensure that requests for CSS (*.css)
    or JS (*.js) files don't submit a request to the server most of the
    time (so the browser just uses its own cached version). Any other url
    would hit a default filter or servlet, which would then delegate to
    other appropriate servlets.

    The only way I can think to do this would be to map all 3 and 2 letter
    extensions that are not CSS or JS to this default filter. Is there no
    NOT wildcard I can use or something?

    Thanks,
    Dale
    Dale, Jan 23, 2004
    #1
    1. Advertising

  2. Dale

    Wendy S Guest

    "Dale" <> wrote in message
    news:...
    > Is there any way in the web.xml, to define the servlet mappings in
    > such a way that I want to map all urls, EXCEPT for particular
    > patterns.


    I don't think so...

    SRV.11.2 Specification of Mappings
    In theWeb application deployment descriptor, the following syntax is used to
    define
    mappings:
    .. 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.

    > Here is my problem.... I want to ensure that requests for CSS (*.css)
    > or JS (*.js) files don't submit a request to the server most of the
    > time (so the browser just uses its own cached version). Any other url
    > would hit a default filter or servlet, which would then delegate to
    > other appropriate servlets.


    I suppose you could just let everything hit the filter, check for .css & .js
    at the top of your Filter and return immediately if it's one of those,
    otherwise go ahead and do your processing. You could put the list of
    "ignore these" extensions in a .properties file or a database and retrieve
    it to avoid hard coding it in the Filter.

    Is it that you don't know what extensions are valid for your app, or you
    think there are too many of them to map?

    (Removed comp.lang.java)

    --
    Wendy in Chandler, AZ
    Wendy S, Jan 23, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Albretch
    Replies:
    2
    Views:
    926
    William Brogden
    Jul 11, 2003
  2. Fran Cotton

    Servlet URL Mapping Evil!

    Fran Cotton, Jul 25, 2003, in forum: Java
    Replies:
    0
    Views:
    3,353
    Fran Cotton
    Jul 25, 2003
  3. Fran Cotton

    Servlet Mapping - What's the point?

    Fran Cotton, Aug 7, 2003, in forum: Java
    Replies:
    3
    Views:
    562
    Tor Iver Wilhelmsen
    Aug 8, 2003
  4. Troy Makaro

    simple servlet-mapping question

    Troy Makaro, Aug 27, 2003, in forum: Java
    Replies:
    0
    Views:
    314
    Troy Makaro
    Aug 27, 2003
  5. circuit_breaker
    Replies:
    2
    Views:
    1,983
    Jack Jia
    Apr 4, 2004
Loading...

Share This Page