• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Servlet Calling Twice on One Submit Request

 
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
doPost method is calling twice through internet explorer don't getting the reason.
Submission is done through javascript form.action() method. No Action is defined in form tag itself.

I Have done few commenting in servlet. Kindly help

Commenting Done by me is here under:

INFO: Starting of servlet
INFO: ActionMode -> Search
INFO: Entering Try Statement
INFO: Query select * from Something where that_thing = '2'
INFO: gConn value = null
INFO: Config e:\IACConn.xml
INFO: New Connection Detail = oracle.jdbc.driver.OracleDriver ; jdbcracle:thin:@192.168.1.17:1521:baya ; vie ; vie123

INFO: Starting of servlet
INFO: ActionMode -> Search
INFO: Entering Try Statement
INFO: Query select * from Something where that_thing = '2'
INFO: gConn value = null
INFO: Config e:\IACConn.xml
INFO: New Connection Detail = oracle.jdbc.driver.OracleDriver ; jdbc:oracle:thin:@192.168.1.17:1521:baya ; vie ; vie123

INFO: G results => oracle.jdbc.driver.OracleResultSetImpl@13df4df
INFO: Entered Finally


INFO: %%%%%%%%%---Entered in Jsp Page---%%%%%%%%%
INFO: RSMessages Resultset Contain => oracle.jdbc.driver.OracleResultSetImpl@13df4df
INFO: gConn value = oracle.jdbc.driver.OracleConnection@97623d
INFO: Use Existing Connection

INFO: G results => oracle.jdbc.driver.OracleResultSetImpl@779a38
INFO: Entered Finally


INFO: %%%%%%%%%---Entered in Jsp Page---%%%%%%%%%

INFO: RSMessages Contain => oracle.jdbc.driver.OracleResultSetImpl@779a38

INFO: gConn value = oracle.jdbc.driver.OracleConnection@d16d9f
INFO: Use Existing Connection



Thank you Bear
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess there is a problem with IE. Once I had also faced the same problem. Just try it with firefox or any other browser to confirm...
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's most likely that you form is being submitted both though its default action as well as through JavaScript. The problem does not lie in the servlet itself.
 
Azrael Noor
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So how to get away from this problem, Only Internet Explorer is to be used to access this. So kindly tell me some method.

There are more then 1 submit buttons, on the page. So i used javascript to submit the form.

Do you guys have any solution?

and ya there was not problem with firefox only with IE!!!
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moved to the JavaScript forum.

Azrael Noor wrote:There are more then 1 submit buttons, on the page. So i used javascript to submit the form.


Why?
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If your button has type="submit" then you will have 2 form submissions. One way to avoid this is to turn your button into a normal "button".
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

T. Huy Nguyen wrote:If your button has type="submit" then you will have 2 form submissions. One way to avoid this is to turn your button into a normal "button".


That's not a very good thing to do. If there isn't a submit button, then the form will not submit on an Enter in a form field. There are better ways to control form submission, but until the original poster answers my question, it's hard to give any further advice.
 
T. Huy Nguyen
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:

T. Huy Nguyen wrote:If your button has type="submit" then you will have 2 form submissions. One way to avoid this is to turn your button into a normal "button".


That's not a very good thing to do. If there isn't a submit button, then the form will not submit on an Enter in a form field. There are better ways to control form submission, but until the original poster answers my question, it's hard to give any further advice.


Agree with you. But IMO, it's the most straightforward.

An alternative would be returning false when onclick occurs:
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

T. Huy Nguyen wrote:Agree with you. But IMO, it's the most straightforward.


Taking it easy during development at the expense of the end user is not a good strategy or practice.

An alternative would be returning false when onclick occurs:


A much better approach.

And I'm fairly sure this is the poster's problem. The form is most likely being submitted by its default action, as well as being submitted by script.
 
reply
    Bookmark Topic Watch Topic
  • New Topic