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

how to interconnect 2 mdlets and servlet??

 
Rajeev Sachdev
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ranchers
can anyone let me know how can we connect 2 midlets and in turn connect to a servlet
thnx
Rajeev Sachdev
 
Daryl Wilding-McBride
Author
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you tell us more about what you need to do, especially the "connecting two midlets" part?
To connect to a servlet from a midlet, you could do something like this:
HttpConnection c = (HttpConnection)Connector.open(urlString);
DataInputStream dis = c.openDataInputStream();
byte[] buffer = new byte[(int)c.getLength()];
dis.readFully(buffer);
result = new String(buffer);
This fragment should be in a try-catch-finally block, with a c.close() call in the finally block, just to tidy things up.
[ July 19, 2003: Message edited by: Daryl Wilding-McBride ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic