ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Two Servlet Filters Every Web Application Should Have
Subject:   MIME types and Servlets that generate binary data
Date:   2004-01-26 21:45:24
From:   jleech
Response to: MIME types and Servlets that generate binary data

But isn't it a goal to make the filters as easy as possible to retrofit to existing applications? Sure, you could go in, add the filters, change lots of links to accomodate them, and add lines of code to web.xml to map everything -- Or just cache the response headers along with the rest of the response and everything is much simpler.
Here's a real-world example of a situation where your suggestion wouldn't work -- and you really must do it a different way: A web form that lets the user input a bunch of parameters, including ouput format, e.g. { .pdf, .xml, .csv, .html }.
The only compelling reason I can see to use extensions on the URLs for the content is to satisfy really old, broken versions of Internet Explorer. And you can trick them anyway by appending ?.pdf or &.pdf to the URL...