On click of submit button, Servlet has been called twice. Why?

This can happen if you are calling the javascript function which does document.formName.submit() but the form itself also has an action attribute. Therefore, the form actually gets submitted twice. If you are submitting the page from the javascript, remove the action attribute from the form tag.

if javascript function does document.formName.submit(),

Ensure that the <input type = “submit”> should not be used in <form></form>

In the following, it is reverse

I used <input type = “submit”> in <form></form> but removed the document.formName.submit() from javascript function.

Example:

function callValidation()
{
if( validateDetails() )
{
document.frmLoadEmpDetails.action = “/DailyActivityLogger/TimeSheetRecorder”;
}
}

<form name=”frmTimeSheet”>

callValidation()”/>

</form>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: