Jump to content
Changes to the Jaspersoft community edition download ×

PDF displays as attachment, but not inline.


ktrinad

Recommended Posts

By: Allan Kos - theincongruent

PDF displays as attachment, but not inline.

2004-03-25 15:20

I have an issue regarding PDF generated by servlet. It has worked for me in the past (and I have put it into production). However, in dev something has caused it to fail.

 

For some reason, it is not displaying the generated pdf inline in the browser. I checked the byte length and it is generating the PDF, but the browser just displays a blank screen. I tried setting content-disposition to attachment and it worked that way when I save it to disk (but not when I 'open from location').

 

Here is the code of interest... These settings worked before but are not now. I thought it might have been my system admin that changed something but my inline is still working in production. Are these header settings valid?

 

response.setBufferSize(fromReportGenerator.length);

response.setHeader("Expires", "0");

response.setHeader("Cache-Control", "no-cache");

if(!pTypeOfReport.equals("pdf"))

response.setHeader("Content-Disposition", "inline; filename=""+rpt.getReportName()+"."+pTypeOfReport+""");

else

response.setHeader("Content-Disposition", "inline; filename=""+rpt.getReportName()+"."+pTypeOfReport+""");

 

response.setContentLength(fromReportGenerator.length);

ServletOutputStream out = response.getOutputStream();

 

out.write(fromReportGenerator);

System.out.println("serv:fromSize="+fromReportGenerator.length); //shows valid size

rg=null;

out.flush();

out.close();

 

 

By: Allan Kos - theincongruent

RE: PDF displays as attachment, but not inline.

2004-03-25 16:07

I'll field this one self,

 

Apparantlely, when you attempt to bytestream a pdf file to yourself in IE4+, you had better not do it via a html-form POST. If you have to use a form, use GET method instead of POST.

 

The problem had nothing to do with servlet. Interesting fact though for those people who might be using forms to submit the request for pdf.

 

-Allan

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...