File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

opening pdf file in servlet

 
Anna Madhusudhanan
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I am opening a PDF file using servlet output stream.
It opens a separate application in the acrobat. But the file name is randamly gnerated. i don't know why it gives random names (like AcrCD.tmp).

My code

res.setHeader("Content-length",fileLength);
res.setHeader("Content-type","application/pdf");
res.setHeader("Content-disposition","inline; filename=" + fileName );

res.setContentType("application/pdf");
res.setContentLength((int)file.length());
OutputStream outstream = res.getOutputStream();
while((len=inputstream.read(buffer))>0)
{
outstream.write(buffer,0,len);
}
inputstream.close();
outstream.flush();
outstream.close();

It is not opening with the filename.pdf, it opens with acr01.tmp.
Can any one help regarding this one.

Thanks in advance
Anna
 
dema rogatkin
Ranch Hand
Posts: 294
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try

I remember we had no problems with names.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic