• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sendRedirect Question

 
Scott Russel
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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).]
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Thank you too Frank! You guys are the coolest!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic