Discussion Board

Results 1 to 3 of 3
  1. #1
    Regular Contributor
    Join Date
    Feb 2006

    Problems with HTTP POST

    Hi, I have some serious problems with the HTTPConnection interface for J2ME. I'm trying to get a persistent connection with a HTTP 1.1 server but I can't achieve it! What I really want is to send some "chunked data" to the sever and then the server processes them separately! I don't know how to get it and I need your help!

    I've read in the HTTP 1.1 RFC and in a lot of websites that the server and the client can close the HTTP connection if they include the "Connection" Header with the value "close". I'm extremely amazed that it doesn't exist a token like "open" to signal that the connection is persistent when the client does the POST request to the server! I don't want to send that "chunked data" in different HTTP connections, so I need a persistent connection!

    Some questions for you:

    1) If I write in an outputStream associated to the HTTP connection more than once, Will an Exception take place? Will the server receive the data?

    2) How can the server receive those "chunked data" and decode them in a good way?

    3) Why the HTTP architecture works so well in J2ME when the server sends data (chunked data or normal data) to the client but not when the roles change?

    4) Do you have some problems with HTTP POST in J2ME?

    I must tell you tha I'm using "Ethereal" tool, and I've advised that by default, an HTTP connection in J2ME has the "Connection" Header with the value "close" and if I explicitly write the value "open" in that Header, in the packet received by the server appears the token "close" again!

    Please, help me with your ideas!

    Here is a piece of my code:

    httpConnection=(HttpConnection) Connector.open(url,Connector.READ_WRITE);

    //Set the request method and headers
    httpConnection.setRequestProperty("If-Modified-Since","29 March 2006 20:00 GMT");
    httpConnection.setRequestProperty("User-Agent","Profile/MIDP-2.0 Configuration/CLDC 1.1");

    //Open the OutputStream
    OutputStream os = httpConnection.openOutputStream();

    //Send the request body
    byte[] buffer=new byte[3];
    ByteArrayOutputStream baos=new ByteArrayOutputStream();
    baos.write("idPaciente=Emilio&idSensor=sensorE&tramaF1=".getBytes() baos.write(buffer); httpConnection.setRequestProperty("Content-Length",Integer.toString(baos.size())); os.write(baos.toByteArray());

    //Get the response code and displays it in the Form

    buffer[2]=(0x63); baos.write("idPaciente=Emilio&idSensor=sensorE&tramaF1=".getBytes());
    baos.write(buffer); httpConnection.setRequestProperty("Content-Length",Integer.toString(baos.size()));

    Last edited by Summerman; 2006-05-02 at 14:04.

  2. #2
    Registered User
    Join Date
    May 2006

    Re: Problems with HTTP POST

    Please try sending the header value: Keep-Alive (instead of "open")
    I also encountered problems with HTTP POST and this issue,
    Let me know if you succeed.

  3. #3
    Registered User
    Join Date
    Nov 2006

    Re: Problems with HTTP POST

    I tried this..but it doesn't work....need same help...

    httpCon = (HttpConnection) Connector.open("http://localhost:9090/my/ImageServlet", Connector.READ_WRITE);


Similar Threads

  1. HTTP POST using Nokia 7650
    By mikael_kinnunen in forum Mobile Java Networking & Messaging & Security
    Replies: 8
    Last Post: 2008-08-19, 23:32
  2. HTTP Client - Synchronous HTTP POST Calls?
    By symbian_ravi in forum Symbian Networking & Messaging (Closed)
    Replies: 5
    Last Post: 2006-04-16, 11:51
  3. Does Vodafone UK wap gateway supports HTTP POST?
    By jessicay in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2004-07-06, 15:27
  4. Problems with sending http post from 7650
    By dotomaz in forum Mobile Java General
    Replies: 2
    Last Post: 2002-12-23, 09:49
  5. 7650 J2ME/MIDP HTTP Post
    By cwalkinshaw in forum Mobile Java General
    Replies: 2
    Last Post: 2002-10-23, 10:12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts