struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brown, James" <james.br...@ca.unisys.com>
Subject Problems streaming PDF over HTTPS to IE
Date Thu, 08 Jan 2004 20:35:31 GMT
We are having a problem streaming a PDF to Internet Explorer over HTTPS.  I have located a
number of postings (namely http://support.microsoft.com/default.aspx?scid=kb;en-us;316431)
that denote this as a known feature/bug in IE; however, we can't seem to get the solution
correct.

As we would like all of the application to be non-cacheable, we have set the following in
the struts-config.xml
  <controller>
    <!--  Set pages as no-cache -->
    <set-property property="nocache" value="true"/>
  </controller>
Which works as expected.

In the Action class we attempt to override the nocache via:
          response.setHeader("Cache-control", "");

This does not appear to have the effect of overriding the controller setting.

Any thoughts?


                                  Cheers,
                                  James
Below is a larger snippet from the Action.execute(...) method.


  public ActionForward execute(ActionMapping mapping,
                               ActionForm form,
                               HttpServletRequest request,
                               HttpServletResponse response)
    throws IOException, ServletException {
    HttpSession sess = request.getSession();

    String report = "XYZ.pdf";
    // stream the PDF data to the browser
    if (report != null) {
      javax.servlet.ServletOutputStream sos = response.getOutputStream();
      try {
        response.setContentType(PDF_MIME_TYPE);
        // as per http://support.microsoft.com/default.aspx?scid=kb;en-us;316431
        // Internet Explorer will not be able to display the PDF in SSL unless
        // the page is set to be cacheable
        response.setHeader("Cache-control", "");
        File reportFile = new File(report);
        FileInputStream fis = new FileInputStream(reportFile);
        byte[] fisBytes = new byte[(int) reportFile.length()];

        fis.read(fisBytes);
        response.setContentLength(fisBytes.length);
        sos.write(fisBytes);
        sos.flush();
        sos.close();
      } catch (Exception e) {
        ActionErrors errors = new ActionErrors();
        errors.add(ActionErrors.GLOBAL_ERROR,
                   new ActionError(Constants.ERROR_KEY_HDR + Constants.LC_ERROR_HDR + "5001"));
        saveErrors(request, errors);
      } finally {
        sos.close();
        response.reset();
      }
    }
 . . .
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus
for use only by the intended recipient. If you received this in error, please contact the
sender and delete the e-mail and its attachments from all computers. 

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message