Technote

(troubleshooting)
Duplicate requests and related errors caused by unwanted HTML form submits
Problem(Abstract)
You see double click requests being generated on the WebSphere Application Server logs. Testing in a controlled environment shows that customers are clicking only once, but two requests are generated from the browser and sent to the Application Server.
Symptom You can see different symptoms such as BusinessContext errors in the logs, a blank page at the time the form is submitted (for instance, after logon), or invalid cookie errors. Cause How the form that submits the request is coded. The code generates requests due to two submits occurring in the code. Resolving the problem Ensure you have only one submission of the form at a time. In this case, removing the form.submit() from makeLowerCase() will resolve the issue.

In many cases, programmers will add additional functions around their form submits to allow specific actions. For instance, a function that is always called before submit that will convert part of the information submitted in the form to lower case.

In order to explain the above, look at a logon form to see how this can be avoided.

The logon form will look as follows:

<html:form method="post" onsubmit="javascript:makeLowerCase(document.LogonForm)" action="Logon" styleId="loginform" styleClass="mainform">
..........
..............

The makeLowerCase function looks as follows:

<script language="javascript" type="text/javascript">
   function makeLowerCase(form)
   {
      form.logonId.value = form.logonId.value.toLowerCase();
      form.submit()
   }
</script>

As you can see in the preceding code samples, the new function makeLowerCase() ensures that the userId submitted in the logon form is always changed to lower case before submission.
Note that the makeLowerCase() method has a built in form.submitI(); Similarly, the form where the function is used, has an onsubmit event tag that will also submit the form. When the user clicks the submit button once, the result of this code will be two separate requests to the Application Server.

If you have the above problem in your code, several things in the logs and storefront can point you to the cause.

Symptoms to look for in the logs and on the storefront

  1. ERR_INVALID_COOKIE in the storefront after the form submit.

  2. GenericError in the Storefront

  3. BUSINESSCONTEXT exception in the logs

    [1/8/08 18:10:18:996 GMT] 0000004b CommerceSrvr  E com.ibm.commerce.webcontroller.WebControllerHelper commitRequestProcess(RequestHandle,boolean,boolean,boolean CMN0409E: The following error has occurred during processing: "com.ibm.commerce.context.exception.
    BusinessContextServiceException: The following create operation exception has occurred during processing: "javax.ejb.DuplicateKeyException".".com.ibm.commerce.
    context.exception.BusinessContextServiceException: The following create operation exception has occurred during processing: "javax.ejb.DuplicateKeyException".
    at
    com.ibm.commerce.component.contextserviceimpl.
    ActivityTokenProcessor.persistActivityToken(Unknown Source)......
    .........

  4. The WC_SERVER trace will also identify this problem. You should see one request to the LogonForm immediately followed by two requests to the LogonCmd instead of one.

    The LogonForm request will look like:
    [1/8/08 18:09:42:898 GMT] 00000049 WC_SERVER     3 com.ibm.commerce.webcontroller.RuntimeServletFilter doFilterAction URLINFO -
    Method = GET
    ServletPath = /servlet
    PathTranslated =
    /opt/IBM/WebSphere/AppServer/profiles/demo/installedApps/
    WC_demo_cell/WC_demo.ear/Stores.war/LogonForm

    The First LogonCmd request will usually be the same thread (here 00000049)
    [1/8/08 18:10:14:465 GMT] 00000049 WC_SERVER     3 com.ibm.commerce.webcontroller.RuntimeServletFilter doFilterAction URLINFO -
    Method = POST
    ServletPath = /servlet
    PathTranslated =
    /opt/IBM/WebSphere/AppServer/profiles/demo/installedApps/
    WC_demo_cell/WC_demo.ear/Stores.war/Logon

    The second LogonCmd request will look as follows:
    [1/8/08 18:10:14:825 GMT] 0000004b WC_SERVER     3 com.ibm.commerce.webcontroller.RuntimeServletFilter doFilterAction URLINFO -
    Method = POST
    ServletPath = /servlet
    PathTranslated = /opt/IBM/WebSphere/AppServer/profiles/demo/installedApps/
    WC_demo_cell/WC_demo.ear/Stores.war/Logon



Note the different thread Id in the second request and how close the timestamps are to each other:
[1/8/08 18:10:14:465 GMT] versus [1/8/08 18:10:14:825 GMT].

Users will usually not click this fast. If the requests are this close, the issue is likely with the code invoked.
 

Document Information

Current web document: http://www.ibm.com/support/docview.wss?uid=swg21294840