Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with duplicated execution of action class

 
Scott Britton
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I'm having what seems to me a very strange problem. I'm developing an application that allows additions to a database. When I go through the hierarchy of the screens, enter the data on the jsp to add to the db and submit, my database add query is successfully executed - twice!

Oddly, if I 'hesitate' on the add screen and wait a minute or so before submitting, the query is only executed once. It behaves as though a duplicate thread is being spawned, using the same http request.

Has anybody ever heard of such a problem before? I've gone over my struts config file and everything several times, and will continue to do so, but I was hoping somebody might be able to enlighten me somehow.

I'm absolutely positive that the behavior I've described is what's actually happening (I'm not an idiot, though I sometimes act like one). I compiled with AspectJ and defined a pointcut to display (println) every method invocation. Also, just plain old println's in the methods show the same thing.

Is there any sort of a context block maintained by Struts which would be available to me programmatically - i.e. something similar to an 'Action.getPriorMapping()' call which would show what Struts has currently for whatever would be analagous to a call stack? Or any way for me toe verify that struts is hearing what I believe I'm saying?

The flow is as follows:
  • Form A - Display all contracts
  • Form B - Display an individual contract, with separate line items
  • Form C - Display an individual line item, with it's detail data
  • Form D - Display all shipments that apply to the current contract line item
  • Form E - Display an 'Add Shipment' form (jsp) which allows entry of a new shipment



  • All forms are JSPs. When new shipment data is entered, I want to add it to the database and go back to Form C via ActionParameters.setForwardName() to the JSP named in struts-config <global-forwards> section. I tried changing to go back to Form B instead, and observed the same behavior.

    Any help much appreciated.

    Thanks,
    Scott
     
    Brent Sterling
    Ranch Hand
    Posts: 948
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    The only time that I saw something like this was when I had an html:submit button and in the onClick it executed some code that called submit(). This caused the form to be submitted twice. I switched it over to an html:button.

    - Brent
     
    Scott Britton
    Greenhorn
    Posts: 4
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    That was it. Thanks so much, Brent!

    I previously had <input type="submit", changed it to Struts tag <html:button and that problem went away. I then needed to get my parameters passed into javascript, done as follows:

    <html:button value='Value'
    property='yo'
    onklick='<%= "return doSubmit(\'" + vendorName +
    "\',\'" + contractNumber +
    "\',\'" + doNumber +
    "\',\'" + partNumber +
    "\',\'" + deliveryId +
    "\',\'" + itemId +
    "\',\'" + delQuantityDue +
    "\',\'" + delQtyToShip + "\');"%>'>
    Save
    </html:button>
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic