Making multiple HTTP requests using same HttpConnection object in j2me

R

Ravi Ambros Wallau

Hi:
I'm developing an application that should make a serie of requests,
using the POST method and transfering binary data, to our HTTP server.
If I use the method Connector.open(url), and then call the methods
openDataOutputStream() and openDataInputStream, everything works fine.
But, when making multiple calls, I'm sure that this is not the best
way to do that.
I've tryed to use the keep-alive feature of http connections, but I
really can't figure how. I've tryed something like this:

HttpConnection hc = (HttpConnection)Connector.open(url);
... set headers
DataOutputStream out = hc.openDataOutputStream();
out.write(...);
out.flush();
out.close();
DataInputStream in = hc.openDataInputStream();
in.read();

... Cycle is finalized - now, if I make this:
out.write(...);
out.flush();
out.close();

... or this:
out = hc.openDataOutputStream();

I receive an IOException with the message "Connection is already
open".
I'm looking for some help on Internet (using google), but there are
few articles about the topics I'm searching for.

Thanks,
Ravi.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top