wood burning stoves 2.0*
The moose likes Servlets and the fly likes sendRedirect Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "sendRedirect Question" Watch "sendRedirect Question" New topic
Author

sendRedirect Question

Scott Russel
Greenhorn

Joined: Dec 04, 2000
Posts: 5
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

Joined: Jan 07, 1999
Posts: 6920
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.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Scott Russel
Greenhorn

Joined: Dec 04, 2000
Posts: 5
Thanks a lot Frank! I'll give a try.
Scott Russel
Greenhorn

Joined: Dec 04, 2000
Posts: 5
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

Joined: Jan 31, 2000
Posts: 1467
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

Joined: Dec 04, 2000
Posts: 5
maha - thank you very much!
It worked and you are wonderful! Java Ranch is the best!
Scotty
Scott Russel
Greenhorn

Joined: Dec 04, 2000
Posts: 5
Thank you too Frank! You guys are the coolest!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sendRedirect Question
 
Similar Threads
PDF Streaming on iOS devices
DownLoading a PDF File
jasper report pdf plugin
pdf in web browser
Struts2- Files DownLoad(Streaming) - as inline , attachment