×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    2

    Problems with Parameters in Servlet

    Hello,
    I want a 7650 to send a String from a textfield as a parameter to a servlet. It works fine with the sun and nokia emulators but the 7650 does not seem to send anything to the server. I even hardcoded the parameter in the String, but still it only works with the emulators...
    Any known problems with the 7650 - Servlet - Communication???

    Thanks a lot!

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    14
    I don't know for sure, but I had this same problem and I put "conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded")" and it worked. Try the code above.

    formData="action=list";





    private DataInputStream process(String formData){
    try{
    //conn.setRequestProperty("Connection","close");
    byte[] data=formData.getBytes();
    //conn.setRequestProperty("content-Length", Integer.toString(data.length));
    conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

    OutputStream os=conn.openOutputStream();
    os.write(data);
    os.close();

    int rc=conn.getResponseCode();
    if (rc==HttpConnection.HTTP_OK){
    DataInputStream dis=new DataInputStream(conn.openDataInputStream());
    return dis;
    }

    }catch (Exception e){
    System.out.println("Error processing game into the server:" + e.getMessage());
    }finally{
    try{
    conn.close();
    }catch (IOException e){
    System.out.println("Error closing connection:" + e.getMessage());
    }
    }
    return null;
    }

Posting Permissions

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