20050323 Wednesday March 23, 2005

How IE handles PDFs From the Struts User Mailing List, I spotted a good explanation of how IE handles PDFs. It's quite messed up, so I thought I'd post it for your amusement.

If your application returns data that is to be handled with an ActiveX control (ie Adobe Acrobat Reader) the browser sends additional requests to the server. In IE 4.x and 5 it actually sends three requests. For IE 5.5+ it sends two.

Assuming that your using IE 5.5+, the first request is the original request (duh), but then IE sends a second request to get the content-type. Who knows why they can't figure this out on the first request ;) This second request has it's userAgent header set to "contype". You can solve this problem and increase the performance of your application by writing a Servlet filter that sits in front of whatever Actions you have setup to serve PDF content. Have this filter look at the userAgent header of each request. If it's set to "contype" just send an an empty response back to the client with the content type set to "application/pdf". Simple as that.

More info on this "feature" is on Microsoft's site. Posted in Java at Mar 23 2005, 09:29:56 PM MST 2 Comments

Comments:

Sounds like this filter would be a good addition to AppFuse, or perhaps to Spring?

Posted by David Carter on March 24, 2005 at 06:41 AM MST #

Very cool, Matt, thanks. I'm currently contracting for a real estate agency and we want to provide PDFs for each property in their database. This can definitely save some bandwith (if I understand the Micro$oft article correctly, you're actually sending two or three copies of the PDFs in most instances). Keller

Posted by Keller on March 25, 2005 at 06:26 PM MST #

Post a Comment:
  • HTML Syntax: Allowed