This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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 Android Security Essentials Live Lessons this week in the Android 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.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Wildcard mapping
Similar Threads
.jspf file not behaving as .jsp file: example in HFSJ
JSF application on Apacher web server and Tomcat
question about weblogic
Sending images to a midlet.
Maintaining session between JSPs