| Author |
Saving binary data as images on the client machine
|
Srikanth Madasu
Ranch Hand
Joined: Sep 10, 2008
Posts: 48
|
|
Hi All, I have an application where user uploads a file and then we need to process the file and after that pull some images from from DB(binary data) and save this data as images on the client machine. I have some prob in saving the images on client machine.
I am using the following code in my action class : but this saves files on the server :
I did some research and found that ServletOutputStream is actually used in downloading files from server to client. But I am not sure if I could use this class to save the binary data.
Any help would be greatly appreciated
Thanks in advance..
--Srik
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56529
|
|
You cannot directly write files to a client system. Think of the nightmarish security implications if you could!
Rather, you must make the file available for download, and the user can choose to save the file or not.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Lorand Komaromi
Ranch Hand
Joined: Oct 08, 2009
Posts: 276
|
|
|
Yes, you could write it to the servlet's output stream to send it to the client (after sending the appropriate Content-type header), but if you're using Struts 2, you can use the stream result (struts 2 stream result)!
|
 |
Srikanth Madasu
Ranch Hand
Joined: Sep 10, 2008
Posts: 48
|
|
|
Thank you guys for your replies..
|
 |
 |
|
|
subject: Saving binary data as images on the client machine
|
|
|