×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    9

    How to Prevent Multiple Submit of Form

    Hello,

    Out company has just developed a j2me program for sales personal to place order from mobile phone. The program is developed using netbeans 6. The connection to the the server is using http protocol via gprs or 3G.

    There is a problem that we face; sometimes we there are duplicate entries from the one mobile request. For example, A sales personal placed an order and press the send button to the server.. The server incoming log sometimes will have multiple request from this this request..

    public void send()throws IOException
    {
    //mainS = null;
    Days = "";

    if (mainS == null){
    getAlert1().setString("Invalid Input lala");
    throw new IOException("Invalid Input lala");
    }

    String onum = getonum();

    StringBuffer b = new StringBuffer();
    String url = server + "?act=i&unm=" + uname + "&upw=" + upw + "&icode="Icode"&onum="+onum "&dd=" getDates() + "&num=" + mainS;
    System.out.println(url);
    try{
    //Connect to the server
    HttpConnection hc = (HttpConnection) Connector.open(url);
    //Authentication

    System.out.println(hc.getResponseCode());

    if (hc.getResponseCode() == HttpConnection.HTTP_OK) {

    InputStream is = hc.openDataInputStream();
    int ch;

    while((ch = is.read()) != -1) {
    b.append((char) ch);
    }
    System.out.println(b.toString().trim());

    returnS = b.toString().trim();

    is.close();

    }else{
    getAlert1().setString("No respon from server.");
    hc.close();
    throw new IOException("No respon from server.");
    }

    hc.close();
    }catch(Exception ex){
    getAlert1().setString(ex.getMessage());

    throw new IOException(ex.getMessage());
    }

    }

    Please help.

    Rgds.

    Kok

  2. #2
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Thumbs up Re: How to Prevent Multiple Submit of Form

    Hi,
    How are putting the request on the server..I means is it command or any other key..Again I would like to ask that are you working with Form or canvas..?

    Is the same thing is gonna happen on the emulator..or just it is happening on device....itself.

    If you are working on form then you can debug the same on emulator..and check that how many times it entering in the commandListener()..while command is pressed once..for the Canvas you can check for the keyPressed()...

    One more thing is it happening on the every device or on a particular one.

    Hope that these lines can be of any help.
    Thanks,
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  3. #3
    Registered User
    Join Date
    Nov 2008
    Posts
    9

    Re: How to Prevent Multiple Submit of Form

    We use canvas. We have tested in S40 devices. We don't face this problem in emulator. What I can say is, it happens during a peak hour where multiple devices send requests to the server. We also suspect that a bad gprs connection causes this problem.

    Rgds.

  4. #4
    Registered User
    Join Date
    Nov 2008
    Posts
    9

    Re: How to Prevent Multiple Submit of Form

    We use a string to submit the request to server via http protocol. When a user completed the entry in the canvas, just press a send button to send the request string to the server.

  5. #5
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Thumbs up Re: How to Prevent Multiple Submit of Form

    Hi,
    Are you sure that it can not happen if user presses the send key twice...make sure first this thing ..

    Thanks,
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  6. #6
    Registered User
    Join Date
    Nov 2008
    Posts
    9

    Re: How to Prevent Multiple Submit of Form

    Whenever we press the send button, the system will jump to another wait screen.. We assume it will not send more than 1 times. But I will chk the code again..

  7. #7
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Thumbs up Re: How to Prevent Multiple Submit of Form

    Hi,
    Make this sure ...might be there is some issue in code and thats comes on some particular condition...check and debug the same..Thanks
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  8. #8
    Regular Contributor
    Join Date
    Mar 2005
    Location
    Hamburg, Germany
    Posts
    285

    Re: How to Prevent Multiple Submit of Form

    Hello Kok,

    look like you have a design problem in the protocol. These are the second hardest to fix. (hardest are if you want to use J2ME to do something outside the sandbox, like reading normal SMS Inbox...)

    In the mobile internet world, your solution need to handle interrupts of the network, (and also stupid users thats send data two times). It happens. The users are on the move.

    For example
    Mobile sends data
    -> server recieves and stores data
    -> server sends back response.
    now interupt, and the mobile will not receive the response.
    The mobile does not know if the server received data.
    So it may need to send again.
    There can also be proxys or so called "transcoders" between your mobile and your server, which make things to your http traffic that somebody with good manners should never do...

    One solution: the mobile sends also a counter. It only increments the counter if the data was changed. The server remembers the last received counter. It doesn't store data if they are already stored.

    Regards
    Karsten Meier

Similar Threads

  1. Form troubles
    By matdodgson in forum Symbian User Interface
    Replies: 2
    Last Post: 2008-12-06, 10:49
  2. SMS on form submit
    By shubhamshukla7 in forum Mobile Java Networking & Messaging & Security
    Replies: 3
    Last Post: 2008-09-30, 12:44
  3. How to submit a form
    By antontul in forum Browsing and Mark-ups
    Replies: 2
    Last Post: 2005-03-16, 13:33
  4. Can't submit form in Nokia 6600
    By a_d_matthews in forum Browsing and Mark-ups
    Replies: 2
    Last Post: 2004-09-17, 17: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
  •  
×