aspose file tools
The moose likes Servlets and the fly likes web.xml servlet url-pattern mapping problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "web.xml servlet url-pattern mapping problem" Watch "web.xml servlet url-pattern mapping problem" New topic

web.xml servlet url-pattern mapping problem

Brian M Smith
Ranch Hand

Joined: Aug 13, 2009
Posts: 35
I'm not sure if I'm going to be able to do this, but figured I would ask.

I need to create a servlet to handle multiple URL patterns. My servlet needs to be able to handle a pattern that looks like this /*/leftNav/*

I'm not a I little confused by what the servlet 2.4 spec means by "A string beginning with a ‘/’ character and ending with a ‘/*’ suffix is used for path mapping." Does this mean multiple wildcard characters may not be used when defining a url-pattern? When I attempt to load the url http://localhost:8080/test/leftNav/somethinghere.js, I'm getting a blank page returned to me. This shouldn't be happen as the servlet will output a test string on the page.

Any ideas?
Frits Walraven
Creator of Enthuware JWS+ V6

Joined: Apr 07, 2010
Posts: 1929

Hi Brian,

Multiple wildcard characters in URL mapping is not allowed.

You have to options:
  • You either write all paths like: /test/leftnav/*
  • or
  • Use the default mapping "/" (as a last resort)

  • Regards,
    Bear Bibeault
    Author and ninkuma

    Joined: Jan 10, 2002
    Posts: 62291

    General wild-card patterns are not supported. So, no, the leading wild-card will not work.

    What are you really trying to accomplish?

    [Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
    Brian M Smith
    Ranch Hand

    Joined: Aug 13, 2009
    Posts: 35

    Thank you for the reply. That is what I thought was going on. I will just come up with another solution.

    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    subject: web.xml servlet url-pattern mapping problem