Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sending images over HTTP

 
Jari Kemppinen
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to send images over a HTTP connection from MIDP 2.0. I'm receiving the images on a Tomcat 5.0 server. I have successfully sent an image that is 2016 bytes in size, but as soon as the image is larger than that the servlet refuses to accept it. Can anyone help me. It's the last thing I have to do for this current project. I've studied this post with no success http://www.coderanch.com/t/227896/JME/Mobile/sending-image-server-HTTP-connection

Client Side-
DataOutputStream os = new DataOutputStream(hc.openOutputStream());
os.write(sendData, 0, sendData.length);
os.close();

Server Side-
int len = req.getContentLength();
byte[] b = new byte[len];
ServletInputStream in = req.getInputStream();
DataInputStream din = new DataInputStream(in);
din.read(b, 0, len);
File f = new File("c:/test.png");
FileImageOutputStream imout = new FileImageOutputStream(f);
imout.write(b,0,len);
imout.close();
 
Joel Karimpil
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jari,

I'm sorry i don't have a solution to ur problem, but i have a doubt.
were u able to display images of size more than 10 KB.
i am using a resize function which does not allow me to do so.
 
Jari Kemppinen
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Joel,

I am displaying an image that is 20k in size no problem currently on emulators. Waiting for the Nokia 6630 before I test the application on a real phone. If anyone can help me out with the http transfer that would be appreciated. Thanks.
 
Jari Kemppinen
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Revisited Michael Yuan's code and got image transfer working great with Tomcat5. If you read this Michael, thanks man, your a legend
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is cool. Thanks for the complement. I am glad that my writing is helpful!
 
marcus russell
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi there i might be a bit of subject but i need help! i bought a nokia 6630 an i have got a virus on it called [yuan] does anybody no how to remove it??? if u do plz e-mail me at marcus_russell@hotmail.co.uk thatnxs a lot ppl!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic