This post originated from an RSS feed registered with Java Buzz
by Matt Raible.
Original Post: How IE handles PDFs
Feed Title: Raible Designs ~ We Build Web Apps
Feed URL: http://static.raibledesigns.com/500.html
Feed Description: Opinions and tips on how to build web applications using Java. Currently using Hibernate, Struts, XHTML, CSS, Ant, JUnit and XDoclet.
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.