wood burning stoves 2.0*
The moose likes Java in General and the fly likes HELP!  Slow response times while dispatching pdf files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic
Author

HELP! Slow response times while dispatching pdf files

Dale DeMott
Ranch Hand

Joined: Nov 02, 2000
Posts: 515
I'm trying to dispatch some pdf files to my browser via a servlet to control who can get to it and who can't. Using a url with .pdf at the end works fast, but it also means everyone can get to them (even if I don't want everyone to get to them) Currently the PDF files are taking quite some time to dispatch. I'm using some file streaming as you can see below. Is there any technique or different classes I can use to speed this up? Maybe a Buffered File Reader??? What would help?

Here's my code...

[ August 06, 2002: Message edited by: Dale DeMott ]

By failing to prepare, you are preparing to fail.<br />Benjamin Franklin (1706 - 1790)
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
A Reader will be useless for a PDF file - it's not text data. A BufferedOutputStream would help - but more useful here would be to use the read(byte[]) and write(byte[]) methods to push bytes in bulk rather than one at a time:

You could try also wrapping the FileOutputStream with a BufferedOutputStream, but I doubt you'd see much further benefit since you've already got one buffer in the system. Experiment with the buffer size to see what works best for you - there's usually a large range in which the size makes little difference.
[ August 06, 2002: Message edited by: Jim Yingst ]

"I'm not back." - Bill Harding, Twister
Dave Landers
Ranch Hand

Joined: Jul 24, 2002
Posts: 401
Seems to me you could put the pdf files in the webapp and add security-constraints in web.xml?
But if you need some kind of programatic security control in the servlet, use buffered streams.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Sigh. Closing this thread since it's now a duplicate, and the I/O forum is more appropriate. Followup here.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HELP! Slow response times while dispatching pdf files
 
Similar Threads
Copying JPEG from one file to another?
Streaming PDF files
Corrupt PDF Files
OutOfMemoryError when accessing Zip File
Streaming to a new web page