Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem sending bytes.

 
Luis Valle
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4391
3
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Luis Valle
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi:
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic