• Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting twice the data in database while inserting through servlet

 
Jasu Yadav
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am getting the data fields twice in println and while inserting in database.
Please help.
Where is the bug?
or any other method can be adopted
Code is as follows-

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you printing HTML from a servlet rather than forwarding to a JSP to emit the view?

And why are you performing a database operation in the middle of the view-generation code?
 
Palak Mathur
Ranch Hand
Posts: 342
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are you trying to do here is simply erratic and should not be followed. Render your view at JSP and not on Servlet and try to separate your Persistence and Presentation logic.
 
shriganesh kakade
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi...
I am also facing the same problem.
I had been separated the design and coding but when the last page (in which the addToDB() method(which includes the actual code to insert the data)is called) is loaded, the data is automatically inserted in the database.
and then after clicking the button again values are inserted.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!