File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes opening pdf file in servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "opening pdf file in servlet" Watch "opening pdf file in servlet" New topic
Author

opening pdf file in servlet

Anna Madhusudhanan
Greenhorn

Joined: Jan 03, 2006
Posts: 8
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

Joined: Oct 09, 2002
Posts: 294
Try

I remember we had no problems with names.


Tough in space?, <a href="http://tjws.sf.net" target="_blank" rel="nofollow">Get J2EE servlet container under 150Kbytes here</a><br />Love your iPod and want it anywhere?<a href="http://mediachest.sf.net" target="_blank" rel="nofollow">Check it here.</a><br /><a href="http://7bee.j2ee.us/book/Generics%20in%20JDK%201.5.html" target="_blank" rel="nofollow">Curious about generic in Java?</a><br /><a href="http://7bee.j2ee.us/bee/index-bee.html" target="_blank" rel="nofollow">Hate ant? Use bee.</a><br /><a href="http://7bee.j2ee.us/addressbook/" target="_blank" rel="nofollow">Need contacts anywhere?</a><br /><a href="http://searchdir.sourceforge.net/" target="_blank" rel="nofollow">How to promote your business with a search engine</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: opening pdf file in servlet
 
Similar Threads
zip files without path info...
FileDownloadServlet
To know about File Upload
displaying an image of type TIF
going to a particular page in a pdf