Title as PDF file name
posted 17 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I want to save the PDF file with the PDF title as name, but its saved as my servlet name.
My servlet (report.java) code as below
String filePath = "C:\report\MyPDF.gzip";
FileChannel fcin = new FileInputStream(filePath).getChannel();
BufferedInputStream bis = new BufferedInputStream( new GZIPInputStream(new BufferedInputStream(Channels.newInputStream(fcin))));
BufferedOutputStream bos = new BufferedOutputStream(new GZIPOutputStream(response.getOutputStream()));
response.setHeader("Vary", "Accept-Encoding");
response.setHeader("Content-Disposition", "inline; filename=MyReport.pdf");
response.setContentType("application/pdf");
for (int i=0; i<1; ++i)
{
bytesRead = bis.read(buff, 0, bufferSize);
if( bytesRead ==-1 ) break;
bos.write(buff, 0, bytesRead);
}
bos.flush();
bos.close();
==
While saving my report it is saved as report.pdf
Pls help me regarding this.
Thanks
vsu
My servlet (report.java) code as below
String filePath = "C:\report\MyPDF.gzip";
FileChannel fcin = new FileInputStream(filePath).getChannel();
BufferedInputStream bis = new BufferedInputStream( new GZIPInputStream(new BufferedInputStream(Channels.newInputStream(fcin))));
BufferedOutputStream bos = new BufferedOutputStream(new GZIPOutputStream(response.getOutputStream()));
response.setHeader("Vary", "Accept-Encoding");
response.setHeader("Content-Disposition", "inline; filename=MyReport.pdf");
response.setContentType("application/pdf");
for (int i=0; i<1; ++i)
{
bytesRead = bis.read(buff, 0, bufferSize);
if( bytesRead ==-1 ) break;
bos.write(buff, 0, bytesRead);
}
bos.flush();
bos.close();
==
While saving my report it is saved as report.pdf
Pls help me regarding this.
Thanks
vsu
posted 17 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Welcome to JavaRanch.
Instead of a disposition of "inline", use "attachment".
Instead of a disposition of "inline", use "attachment".
v su
Greenhorn
Posts: 2
posted 17 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi,
If I changed to Attachment means, its working fine, but I want to display in same page thats why i put inline.
Thanks
vsu
If I changed to Attachment means, its working fine, but I want to display in same page thats why i put inline.
Thanks
vsu
| I was born with webbed fish toes. This tiny ad is my only friend: The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |






