Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HELP! Slow response times while dispatching pdf files

 
Ranch Hand
Posts: 515
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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 ]
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Sigh. Closing this thread since it's now a duplicate, and the I/O forum is more appropriate. Followup here.
 
    Bookmark Topic Watch Topic
  • New Topic