• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Saving binary data as images on the client machine

 
Srikanth Madasu
Ranch Hand
Posts: 48
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you guys for your replies..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic