• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Getting duplicate records when the page refreshes.

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am getting duplicate records while refeshing page. I am doing a JSP/Struts 1.0 web application. Plese see the code in my Action class:

if(action.equals("Submit")){

insertReports(xml);

//xml is of String type which is a xml file

//The table to which this xml is saving ,have primarykey as its Id. Each time when it is inserted, it will take the value as maxximun value of id+1.

return mapping.findForward("AddNewReport");
}

My problem is everytime I refresh the page, the above action get executed and insert a new record this same xml(its id is different). Please suggest a solution for this problem.

Thanks
Soumya
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Write this on top of your jsp code

Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetValidUntilExpires(false);

Cheers!!!

Ujjwal B Soni

[baroda, gujarat, india]
[919998971048]
 
Soumya Madhu
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by ujjwal soni:
Hi,

Write this on top of your jsp code

Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetValidUntilExpires(false);

Cheers!!!

Ujjwal B Soni

[baroda, gujarat, india]
[919998971048]



Hi,
I have given
Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetValidUntilExpires(false);

in top of my jsp. But got errors.

package DateTime does not exist.
package Response does not exist
cannot resolve symbol:
symbol : variable HttpCacheability
etc...

any thing we need to import in jsp page? am using tomcat 4.1 and java 1.4.
 
Ranch Hand
Posts: 1512
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a common problem. Search for the PRG pattern.
 
Marshal
Posts: 67344
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This article describes proper web application patterns including PRG.
 
This is awkward. I've grown a second evil head. I'm going to need a machete and a tiny ad ...
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!