• Post Reply Bookmark Topic Watch Topic
  • New Topic

Refresh from Browser  RSS feed

 
Anand Gondhiya
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • 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
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • 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.
 
friso dejonge
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Wow !!! very informative replies... My senior programmers never told me this...
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • 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
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • 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
  • 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
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
They're working now for me, at least.

Thanks Lasse. I can also read the articles now.

Nick
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!