This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Wildcard mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Wildcard mapping" Watch "Wildcard mapping" New topic

Wildcard mapping

Jan Hansen

Joined: Mar 16, 2006
Posts: 2
I'm converting a site over from using Resin 2.1 (which I'm a lot more familiar with than Tomcat), and I have a question about wildcard mapping. At the moment in the Resin's web.xml file, I have the following:

This basically means that MainServlet will handle all URLs except those matching the patterns specified. I'm not sure how to do the equivalent in Tomcat. I could easily simplify it so that anything with a suffix other than .jsp is handled by a file servlet (i.e, treated as a static page), URLs ending in .jsp are handled by the JSP servlet, and anything without a suffix is handled by MainServlet. How can I accomplish this with Tomcat?

(I should add that if I were designing it from scratch, I would do it the other way round, and ensure that any URLs which needed to be handled by my servlet had an identifiable suffix, but I'm not in a position to do that now, and have to handle whatever is thrown at me).
[ March 16, 2006: Message edited by: Jan Hansen ]
Jan Hansen

Joined: Mar 16, 2006
Posts: 2
Well, I found a kind of solution, although not one I think is especially elegant, which is to do the following for each specific suffix I need the default servlet to handle (much as in the Resin example):

How come the servlet API is so lame in this respect, with regard to pattern matching? Surely the ability to handle regular expressions should not be beyond modern servlet containers?

Incidentally, I should have pointed out that this is in a standalone Tomcat environment, i.e., without Apache, hence the need to handle static pages.
I agree. Here's the link:
subject: Wildcard mapping
It's not a secret anymore!