Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
JSP - A mailing list about Java Server Pages specification and reference
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Subject: Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Subject: Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
serving files through SSL

serving files through SSL

2007-11-07       - By Roger Parkinson

 Back
Reply:     1     2     3  

I am trying to deliver some PDFs to the browser using my tomcat
application. It works, but not always under SSL and IE.
One file is a static PDF and it lives inside my war file. That works
just fine. The file is accessed using a url like /myapp/web/myfile.pdf
and that always delivers the file.
Other files are generated by the app and live in a configured directory.
They are delivered through a servlet that looks like this:

           String mimeType = sc.getMimeType(filename);
           FileHelper helper = new FileHelper();
           InputStream in = helper.fetch(filename, m_dir);
           response.setContentType(mimeType);
         response.setContentLength(10115);
         response.addHeader("ETag","W/\"963288-1194247031062");
           OutputStream out = response.getOutputStream();
           byte[] buf = new byte[1024];
           int count = 0;
           while ((count = in.read(buf)) >= 0)
           {
               out.write(buf, 0, count);
           }
           in.close();
           out.close();

So apart from some minor fiddling with the contentType etc I don't do
very much. This works fine outside of SSL and it also works fine with
SSL and Firefox, but not SSL+IE.
Thinking it was a problem with headers I did some research and found a
lot of stuff about setting no cache etc. Tried it and it nothing made
any difference (except that I managed to break it). I have taken all
those out because the static file, the one I mentioned at first, is
delivering okay to IE over SSL so I don't believe there is a problem at
the IE end, or not one that cannot be overcome by getting my response
right at the server end.

I used TCPMonitor to sniff the headers using non-SSL and found that the
static file has this response:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
ETag: W/"963288-1194247031062"
Last-Modified: Mon, 05 Nov 2007 07:17:11 GMT
Content-Type: application/pdf
Content-Length: 963288
Date: Wed, 07 Nov 2007 04:54:39 GMT
... pdf file follows

So there doesn't seem to be too much going on there.

When I respond to the request for the dynamic file it looks like this:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Pragma: No-cache
Cache-Control: no-cache
Expires: Thu, 01 Jan 1970 12:00:00 NZST
ETag: W/"963288-1194247031062
Content-Type: application/pdf
Content-Length: 10115
Date: Wed, 07 Nov 2007 05:32:02 GMT

...pdf file follows.

I am getting some cache headers added for free otherwise there is no
difference in the request.
Of course those headers may be making all the difference because IE's
message is 'cannot write the file to cache' which is a bit odd because
we've explicitly told it not to here.
Searching the web on this has a number of answers that suggest adding
those no-cache headers anyway.

So, does anyone know what I need to do to make the two responses enough
the same to stop IE complaining?
I am aware that I have faked the ETag and the length of the file and
that I need to do something smarter there, but I'll do that when it
starts working.

Version info: Tomcat 5.5, Java 1.5, WinXP SP2

Thanks for your help.
Roger

-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To start a new topic, e-mail: users@(protected)
To unsubscribe, e-mail: users-unsubscribe@(protected)
For additional commands, e-mail: users-help@(protected)


©2008 junlu.com - Jax Systems, LLC, U.S.A.