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. Advertisements

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. Chad McCune
    Replies:
    2
    Views:
    745
    Chad McCune
    Jan 20, 2004
  2. Marko
    Replies:
    11
    Views:
    19,300
    Marko
    Oct 19, 2004
  3. Endi
    Replies:
    5
    Views:
    14,490
    Darryl Pierce
    Jun 26, 2005
  4. rzimerman

    Making HTTP requests using Twisted

    rzimerman, Jul 11, 2006, in forum: Python
    Replies:
    4
    Views:
    731
    Manlio Perillo
    Jul 11, 2006
  5. Dave Garcia
    Replies:
    5
    Views:
    1,010
    Dave Garcia
    Jun 5, 2009
  6. Christopher Benson-Manica

    Making HTTP requests

    Christopher Benson-Manica, Mar 25, 2005, in forum: Javascript
    Replies:
    2
    Views:
    160
  7. Brian Raymond
    Replies:
    0
    Views:
    227
    Brian Raymond
    Apr 22, 2013
  8. Luca Cerone
    Replies:
    8
    Views:
    350
    Luca Cerone
    Aug 30, 2013
Loading...