• Post Reply 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

sendRedirect Question

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
Say all that I could get back from a bean was a BufferedInputStream. This stream contains a PDF file.
Now I want to "stream" the contents of the BufferedInputSteam to the browser - hence - opening the PDF file.
Sounds strange but is all I have to work with right now.
Unfortunately I can NOT just give the URL to the PDF file as I need to hide it from the browser/user.
Please help if possible and thanks in advance!
Scott
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's easy enough to write a methjod to copy from one stream to another:

You just need to make sure you set the appropriate content type, then copy the input stream to the response.getOutputStream() using the above and finally close the streams.
 
Scott Russel
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Frank! I'll give a try.
 
Scott Russel
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I did it - sort of...
I can get the PDF to the browser now but I think the CONTEXT-TYPE is wrong because it looks like text.
Here is how I thought you should set CONTEXT-TYPE for the response object, is this correct?

Thanks in advance.
[This message has been edited by Scott Russel (edited December 07, 2000).]
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Scott,
Slightly modify the header name like this. It will work. I used this code to diplay a report in Excel format.
regds
maha anna
 
Scott Russel
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
maha - thank you very much!
It worked and you are wonderful! Java Ranch is the best!
Scotty
 
Scott Russel
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you too Frank! You guys are the coolest!
 
My name is Inigo Montoya, you killed my father, prepare to read a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic