This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Servlets and the fly likes download bytes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "download bytes" Watch "download bytes" New topic
Author

download bytes

Fernando Dominguez
Ranch Hand

Joined: Sep 01, 2006
Posts: 104

Hello;

I would like that the browser (firefox) whre able download the zip file from my servlet ( byte array).

I tried the following

... but it doesn't works.

Thanks.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9374
    
  19

Just saying that It Doesnt Work Is Useless. Tell us more details about what is happening...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874



Use ServletOutputStream when you writes write byte data and close the stream after finishing.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3886
    
    5

Fernando Dominguez wrote:I would like that the browser (firefox) whre able download the zip file from my servlet ( byte array).
I tried the following


Hi Fernando,

When you are writing raw bytes you should use ServletOutputStream instead of PrintWriter and write the bytes to the stream (that's just pure Java).


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
 
Don't get me started about those stupid light bulbs.
 
subject: download bytes
 
It's not a secret anymore!