×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Oct 2005
    Posts
    62

    Making Http Post in J2me (HttpConnection)

    Hi guys,

    is there a work around as to how to make an http post in j2me httpconnection lib?

    I know u can set request method but how do u set the properties to be posted?

    Thnx.

  2. #2
    Registered User
    Join Date
    Jun 2006
    Location
    Lahore, Pakistan
    Posts
    162

    Re: Making Http Post in J2me (HttpConnection)

    it is very simple just write your properties as your write else where.

    for example

    String s="param1=abc&param2=123";

    and then write the bytes in an OutputStream like this.

    OutputStream out.

    out=conn.getOutPutStream()
    out.write(s.getBytes());
    out.flush();//optional
    Sajid Iqbal
    ASD, Accredited S60 Developer
    [EMAIL]saji.iq@gmail.com[/EMAIL]

  3. #3
    Regular Contributor
    Join Date
    Oct 2005
    Posts
    62

    Re: Making Http Post in J2me (HttpConnection)

    Quote Originally Posted by saji_iq
    it is very simple just write your properties as your write else where.

    for example

    String s="param1=abc&param2=123";

    and then write the bytes in an OutputStream like this.

    OutputStream out.

    out=conn.getOutPutStream()
    out.write(s.getBytes());
    out.flush();//optional
    Thnx.

    Is there any limit to what I can write to the stream? The GET method can limit the length of URL as in Motorola (256 character).

    Also, how do get it on the server side?
    I use request.getParameterMap() and I dont seem to be gettin the parameter I sent. They aer all null. This is my posted string.


    cmd=bal&n=08000000000&card=def&acct=0&pin=d5da05fb2b809d8f&
    s=a1a639ee5d0caf24c8702ee

    but the receiving server couldnt get anything.

    Also in my url shld I add "?" at the end of the it?

    Thnx

    I just change the posted string to
    ?cmd=bal&n=08000000000&card=def&acct=0&pin=d5da05fb2b809d8f&
    s=a1a639ee5d0caf24c8702ee

    and it was still the same.
    Last edited by lekkie; 2007-02-12 at 18:31.

  4. #4
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    150

    Arrow Re: Making Http Post in J2me (HttpConnection)

    Hi lekkie,
    See this Thread. It might be useful for you!

    http://discussion.forum.nokia.com/fo...d.php?t=101221

    BR.

    Summerman.

  5. #5
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    150

    Lightbulb Re: Making Http Post in J2me (HttpConnection)

    Hi lekkie,
    See this Thread. It might be useful for you!

    http://discussion.forum.nokia.com/fo...d.php?t=101221

    BR.

    Summerman.

    PD: You have to decide if you use a GET or a POST HTTP query! If you send your parameters in the url between '&' characters, you are using a GET query. In the my above url, I bult a POST query. As saji_iq mentioned, you should set my HTTP headers (with GET instead of POST, in the setRequestMethod() call) and then open the OutputStream and send the String 's' as saji_iq said! Referring to the '?' char, I should write it after the basic url (http, host, ip...) and before writing your parameters!

  6. #6
    Regular Contributor
    Join Date
    Oct 2005
    Posts
    62

    Re: Making Http Post in J2me (HttpConnection)

    Quote Originally Posted by Summerman
    Hi lekkie,
    See this Thread. It might be useful for you!

    http://discussion.forum.nokia.com/fo...d.php?t=101221

    BR.

    Summerman.

    PD: You have to decide if you use a GET or a POST HTTP query! If you send your parameters in the url between '&' characters, you are using a GET query. In the my above url, I bult a POST query. As saji_iq mentioned, you should set my HTTP headers (with GET instead of POST, in the setRequestMethod() call) and then open the OutputStream and send the String 's' as saji_iq said! Referring to the '?' char, I should write it after the basic url (http, host, ip...) and before writing your parameters!
    Thnx,

    I ve resolved it. i had to read the stream manually form the servlet

Similar Threads

  1. Problems with http - POST
    By bigbadwolf in forum Symbian Networking & Messaging (Closed)
    Replies: 13
    Last Post: 2007-01-17, 23:45
  2. Can J2ME be used for sending MMS Message ?
    By seno_ap in forum Mobile Java General
    Replies: 1
    Last Post: 2006-11-24, 14:36
  3. Is USA market for J2ME evaporating?
    By pcarew in forum Mobile Java General
    Replies: 12
    Last Post: 2005-10-15, 02:51
  4. Symbian and non Symbian J2ME
    By thongtom in forum Mobile Java General
    Replies: 2
    Last Post: 2005-06-28, 10:52
  5. J2ME Polish: a new build tool for professionals
    By enough in forum Mobile Java Tools & SDKs
    Replies: 1
    Last Post: 2004-05-17, 18:02

Posting Permissions

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