Making multiple HTTP requests using same HttpConnection object in j2me

Discussion in 'Java' started by Ravi Ambros Wallau, Oct 25, 2004.

  1. 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.
    Ravi Ambros Wallau, Oct 25, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marko
    Replies:
    11
    Views:
    18,414
    Marko
    Oct 19, 2004
  2. Endi
    Replies:
    5
    Views:
    14,105
    Darryl Pierce
    Jun 26, 2005
  3. rzimerman

    Making HTTP requests using Twisted

    rzimerman, Jul 11, 2006, in forum: Python
    Replies:
    4
    Views:
    486
    Manlio Perillo
    Jul 11, 2006
  4. Christopher Benson-Manica

    Making HTTP requests

    Christopher Benson-Manica, Mar 25, 2005, in forum: Javascript
    Replies:
    2
    Views:
    74
  5. Luca Cerone
    Replies:
    8
    Views:
    175
    Luca Cerone
    Aug 30, 2013
Loading...

Share This Page