File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes duplicate records Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "duplicate records" Watch "duplicate records" New topic
Author

duplicate records

supriya ratnakar
Greenhorn

Joined: May 15, 2008
Posts: 5
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

Joined: Feb 08, 2008
Posts: 4
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

Joined: May 19, 2008
Posts: 2
Did you use empid as a primary key or composite primary key?


Thanks,<br />Prabhakaran.M
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Shrikant Kesarkar:
... (assuming
struts flow)


We don't assume that Struts is being used unless the original poster says it is.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
supriya ratnakar
Greenhorn

Joined: May 15, 2008
Posts: 5
yes emp id is primary key and i am just using mvc not struts
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

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.


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
lalith kumar
Greenhorn

Joined: May 09, 2008
Posts: 17
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
 
subject: duplicate records