my dog learned polymorphism
The moose likes Servlets and the fly likes Problem sending bytes. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Problem sending bytes." Watch "Problem sending bytes." New topic

Problem sending bytes.

Luis Valle

Joined: Jan 08, 2001
Posts: 13
Hi all!
I want to send an array of bytes with an HTTP servlet to a java client. I tried converting the array of bytes to a String and send with PrintWriter.println(String). The problem is that these bytes don�t come from text information, they are data from another source. I tried using ServletOutputStream, that is used to send binary data instead of text data, but I don�t know what MIME type I should specify. Could you help me?
Thank you,
Best Regards, Luis Angel.
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4351

I dont know if this will help or not.
Since you didnt say you were sending it to an applet.
I sent an int from a servlet to an applet like this:

applet code

anyway the mime type would be one of these:

I am kind of new at this also so I could be wrong.
[This message has been edited by Randall Twede (edited February 22, 2001).]

Visit my download page
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
If it is your Java client which accepts the data, you can use any mime type you like. The mime type is just a hint to th ebrowser how to display the data.

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Luis Valle

Joined: Jan 08, 2001
Posts: 13
When I use the ContentType text/html in the servlet, in the client side, some of the received bytes (a lot of them) were changed always to the value "63": for example, original value=-159 received value=63. It seems that when I send the bytes it modify some characters. Because of this, I think I should specify another ContentType, shouldn�t I?
Thanks both of you!
Best Regards, Luis
I agree. Here's the link:
subject: Problem sending bytes.
jQuery in Action, 3rd edition