File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

duplicate records

 
supriya ratnakar
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when i am creating a record like inserting a record then if i refresh a page same record get inserted again . I am auto incrementing Emp Id. which is a primary key.
but other than that everything else is duplicating.

please reply

Supriya
 
Shrikant Kesarkar
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you are refreshing a page the http event like "/addemployee.do" (assuming
struts flow) is getting fired again as before refreshing the page the
url which made employee record insertion before page refresh is still there
in browsers address bar.There couldn't be new entry if you were editing existing field , I mean "/editemployee.do" kinda functionality.
Whatever happening is quiet natural only instead of you clicking on "submit"
button and in turn it resulting into corresponding action(in this case /addemployee.do)browser directly firing this http event.
But why do you need to refresh your pade anyway?
 
Prabhakaran Manoharan
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you use empid as a primary key or composite primary key?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Shrikant Kesarkar:
... (assuming
struts flow)


We don't assume that Struts is being used unless the original poster says it is.
 
supriya ratnakar
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes emp id is primary key and i am just using mvc not struts
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can handle this problem by using a flag before inserting the row into the database and then false this flag after insertion.

is this help.
 
lalith kumar
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi supriya,

you can solve that problem by redirecting the action to some other page.
In that page you again redirect to your page (whichever you need).



you redirect your actual page to some other page like what i have did and in that page you mention the next page action.

try it
;)
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic