This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

form being submitted twice

 
vishal pala
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

We are having an problem our form being submitted twice and this happening very rarely around once in 2 months, per day this form is submitted around 2000 times. we are disabling the submit button after the button is clicked, Has any one of you have faced this problem if so please can you suggest the possible scenario when it happen As we are not able to recreate the problem in our development/Test environment

Logice is like we have a Jsp after the form is filled and when Submit button is clicked a servlet is called and in that servet we a have a method which perform the logice to create a string of message and sent to MQ queue. Problem is very rarely this same message is created twice and sent to Queue.

thanks in Advance for your suggestions.
vishal
 
Minh Tran
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just make sure the url has been redirected (changed), because user can still press refresh button to resubmit form
 
vishal pala
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Minh,

thanks for your reply, i have checked the URL its not changed and there is difference of fraction of milliseconds in the submitted messages, if we referesh the current page it takes some second again to submit, so i dont think it is happening with referesh and submit. thnanks!!
 
Anupam Sinha
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it happening cross browser? Are you using a submit button image to submit the form. On IE if you use an image to submit a form (without any extra checks to stop the double submission) it would submit he form again. In case of Firefox it would only do a single submit. Please tell us thr browser and what exactly is the submit button?
 
vishal pala
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anupam
thanks for your reply

we are using only Internet explorer 6.0 and we are not having any image on the button our submit is of type Button with onclick

i was trying to submit from other browsers in Test environment but unacle to create that scenairo, its happening in production environment all our user use only IE 6.0



thanks!!
 
Rajesh Agarwal
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sure you would be using a tracelog. You can insert debug statements in the beginning of service method and track from there
 
vishal pala
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi rajesh
thanks for your response
Yes i have looked into my logs of production and what i see is there is just differnce of fraction of milliseconds on them timestamp of the messages, so two requests are sent to the servlet with in difference of fraction of milliseconds but not sure how it is happening in Prod envireonment that too very rarely thanks
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vishal,

Just check out these links.

  • Solving the Logout Problem Elegantly
  • Revisiting the Logout Problem



  • HtH.
    [ June 22, 2007: Message edited by: Raghavan Muthu ]
     
    Saravanan Thoppae
    Greenhorn
    Posts: 13
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Vishal,
    Since you said that the form will be submitted onclick event - i guess you would have submitted the form in a javascript. And please note that the form will be submitted when the focus is on the button and when the user hits enter key.
    So if you have called same javascript for onsubmit of form and onclick of the button then when the user hits enter (when button is on focus) the javascript will be called. But again there is a form submit called in a javascript and hence the double submit.

    Hope this helps.
     
    Venky Babu
    Greenhorn
    Posts: 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi,

    Make sure that you have both doGet() and doPost() methods in your Servlet. If you have only one method, there are chances that can cause form submission twice.

    Please try this.

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    service(request, response);
    // TODO Auto-generated method stub
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    service(request, response);
    // TODO Auto-generated method stub
    }

    Thanks,
    Venky
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Pie
    Posts: 64633
    86
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Venky Babu wrote:Make sure that you have both doGet() and doPost() methods in your Servlet. If you have only one method, there are chances that can cause form submission twice.


    No, this is not correct. There is no way that only having one of these methods implemented can cause a double submission. No way at all.

    In fact, it is quite common to have only one of the methods implemented, and it is a poor practice to have both GET and POST do that same thing.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic