Results 1 to 3 of 3

Thread: How can I restrict the multiple data insertions

  1. #1
    Geek_Guest
    Guest

    How can I restrict the multiple data insertions

    In a Struts application when click on submit it is performing some data base insertion but the end user is keep on clicking on "submit" then how can i restrict the multiple data (means same data form jsp) insertions?

    Question asked by visitor pandu


  2. #2
    Junior Member
    Join Date
    Jan 2008
    Answers
    11

    Re: How can I restrict the multiple data insertions

    Yoy have to write the externally as follows
    int i=request.getparameter("id");
    resultset rs="stmt.executequery("select id form user where id='+i+'); i
    f(rs.next!=true)
    { stmt.executequery("insert into user values());
    }


  3. #3
    Junior Member
    Join Date
    Jan 2007
    Answers
    2

    Re: How can I restrict the multiple data insertions

    We can control this in mutiple ways.

    1. Disable Submit button after first submission (but it fails when user click F5-refresh)
    2. Use Struts Tokens

    you need two action methods, one is for show the JSP and another is for save data
    1. First you have to set the token in first action class method

    saveToken(request);
    return mapping.findForward(target);

    2. and then validate token in save method

    if (isTokenValid(request)) {
    resetToken();
    }
    else {
    mapping.findForward("errorPage");
    }
    ... code for further processing


    But it fails in click browser back button and resubmit. In those cases use redirection instead of forwarding.

    you can use combination above for your problem


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact