aspose file tools*
The moose likes JSP and the fly likes How to prevent new record creation on page reload? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to prevent new record creation on page reload?" Watch "How to prevent new record creation on page reload?" New topic
Author

How to prevent new record creation on page reload?

Tina Desai
Ranch Hand

Joined: Mar 13, 2003
Posts: 365
Friends,
We have the following:

Scenario:
1. We come to a page by creating a record in the db.
2. The user can enter data and save it multiple times.

Issue:
But if user clicks on reload before step 2, the alert box comes to confirm. On ckick of ok, a new record gets inserted.
A. Can we have some workaround that gets the data but does not insert one more record?
B. Can the refresh be disabled? I have not seen it disabled in the web-apps I browsed so far.

Regards,


Alongwith being a good coder, try to be a good professional as well!
Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
Perhaps you are using model 1 principle?

Create a hidden input type

<input type="hidden" name="saved" value="<%request.getParameter("saved")%>">

on submit, check if the parameter has already been set, if not set it to something



Bear would probably hate me by giving this answer but if it will help you(and I hope it will) I guess I'm ok with that...

Do yourself a favor and learn Model 2


SCJP 1.5
http://devpinoy.org/blogs/lamia/ - http://everypesocounts.com/
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Redirect After Post:
http://faq.javaranch.com/view?DoubleSubmitProblem


[My Blog]
All roads lead to JavaRanch
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Do yourself a favor and learn Model 2

Your solution with the hidden param smells like Model 1
[ September 07, 2006: Message edited by: Satou kurinosuke ]
Chetan Parekh
Ranch Hand

Joined: Sep 16, 2004
Posts: 3636
Check DoubleSubmitProblem section in FAQs Section of this forum.


My blood is tested +ve for Java.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Chetan, you should check it too ;) (joking about same post)
Chetan Parekh
Ranch Hand

Joined: Sep 16, 2004
Posts: 3636
Originally posted by Satou kurinosuke:
Chetan, you should check it too ;) (joking about same post)


Hey Satou kurinosuke sorry, I just missed that thing
Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
I was thinking that he might be using model 1 so I decided to give him a solution that fits with it.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Hehe, ok
Richard Green
Ranch Hand

Joined: Aug 25, 2005
Posts: 536
Originally posted by Timothy Sam:
I was thinking that he might be using model 1 so I decided to give him a solution that fits with it.

he? or she?
friday evening here - so please excuse some unrelated posts


MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
Tina Desai
Ranch Hand

Joined: Mar 13, 2003
Posts: 365
Its SHE!

Timothy, I know model 2! Working on some code not written by us

I have one more issue.. Not going to the confirmation page as such..

Left nav link inserts the record.
And immediately displays it for editing..

I have successfully used a token at a place where the confirmation page is displayed on 'submit' click. But here there is no intermediate such button.
Do we even have a chance to get around this problem in this organization/control flow?

Regards,
Leena
[ September 14, 2006: Message edited by: Tina Desai ]
Tina Desai
Ranch Hand

Joined: Mar 13, 2003
Posts: 365
Anyone?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Can you post the relavent part of your code?
Or,, describe step by step what your program is doing so we can make a suggestion.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to prevent new record creation on page reload?
 
Similar Threads
Awkward question (sorry)
How to include different jsp in a page based on the browser java script enabled/disabled condition?
Using a Dynamic Table on My JSP
ajax and struts action class
controlling jsp:forward