This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
  • 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Refresh from Browser

 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

I am using struts and Weblogic 8 on Windows 2000.

When I refresh my JSP page , it adds duplicate records to my database and shows duplicate records on the JSP page also.

I think this is supposed to happen because of populated form-beans right ??

Are considering this as a disadvantage of Struts ? How do you eliminate this problem (i.e NON duplication on Refresh from Browser) ??

Thanks all
-Anand
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're looking for a pattern named "redirect after submit" (or something like that). Our very own UBB forum software here at saloon.javaranch.com uses that very technique to avoid accidental double-posting.
 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
This is not really a struts problem. It is more something that is embedded in your application design. When you refresh on a page that does submit a form, and subsequently adds something in the database you should implement the 'token' design pattern. This basically prevents you from submitting the same form or request twice (which is what you do)

When I refresh my JSP page , it adds duplicate records to my database and shows duplicate records on the JSP page also.



if you do a google on 'form token pattern' you come up with lots of interesting stuff to help you.
regards, and good luck
friso
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...which reminds me that there's such a token facility built in to Struts. Google for "Struts" and "saveToken".
 
Anand Gondhiya
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wow !!! very informative replies... My senior programmers never told me this...
 
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


My senior programmers never told me this...


Maybe just he dont know.

The token is provided internally by Struts. In fact, if Lasse did not tell me before, I dont know as well.

Nick
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm found some article at TSS in your problem ::

Redirect After Get

Redirect After Post
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I cant get into the links.

It gives me the following errors:


Bad Gateway
The proxy server received an invalid response from an upstream server.



Anybody succeed? Is this my own proxy server issue?

Nick
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Nicholas Cheung:
Anybody succeed? Is this my own proxy server issue?


They're working now for me, at least.
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

They're working now for me, at least.


Thanks Lasse. I can also read the articles now.

Nick
 
You got style baby! More than this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic