File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes exclude url-patterns in web.xml's servlet-mapping? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "exclude url-patterns in web.xml Watch "exclude url-patterns in web.xml New topic

exclude url-patterns in web.xml's servlet-mapping?

Eric Martin

Joined: Jul 15, 2005
Posts: 22

I'm in a bit of a situation =) We have set up our web.xml as follows:

This has worked great until today when we added a 3rd party app that uses actualy html files. So now OurServlet tries to process any files that come from /3rdPartyApp/html/*.html. Is there any way to exclude anything that comes form /3rdPartyApp* in the servlet-mapping? Or is there any other way around this, besides changing the filenames or re-mapping our servlet =). The 3rd party app does not need a servlet entry.

[ October 11, 2005: Message edited by: Eric Martin ]
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Well you have *.html. That will include everything. Just change that so that it more accurate. having *.html in the first place is what causes your problem, so don't try to fix your problem by adding something. fix the problem. You mapping should be specific to the detail level that it needs, not to the most generic, which causes maintenance problems later, like you are seeing now.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63858

Mapping *.html to an active resource is a bad idea in any case. And I have the scars to prove it.

Sometimes, "helpful" servers along the way will cache resources that end with .html (or other known static types). This ended up, in a previous job, by serving up data for one customer to another. Yikes. AOL was a big problem with this respect.

I'd avoid mapping servlets to any pattern that could be mistaken for something other than a servlet.

[Asking smart questions] [About Bear] [Books by Bear]
Eric Martin

Joined: Jul 15, 2005
Posts: 22
Thanks for the tips/advice. I changed the .html mapping to .do to fix the problem.
Eddy Lee Sin Ti
Ranch Hand

Joined: Oct 06, 2005
Posts: 135
Although you already have a solution, just to let you know other possible workarounds.

You can have a forwarding servlet for /3rdPartyApp. The servlet just need to use RequestDispatcher to serve the html static files. Also, you can use Filter to achieve the same effect.

SCJP, SCWCD, SCJWS, IBM 700,IBM 701, IBM 704, IBM 705, CA Clarity Technical<br /> <br /><a href="" target="_blank" rel="nofollow"></a>
I agree. Here's the link:
subject: exclude url-patterns in web.xml's servlet-mapping?
jQuery in Action, 3rd edition