• Post Reply Bookmark Topic Watch Topic
  • New Topic

Refresh problem  RSS feed

 
karthik mahalingam
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,

i am developing jsp page that insert the records to database when i am clicking the submit button. I write the insertion code in same jsp page.
When i am click the submit button, set the hidden value to true. If it is true insert the record and display the success message on the same page otherwise not. It works fine. Then what i want , If i am refreshing the page again again insert the record. What to do..

Please give me a solution


Karthik
 
Himanshu Bisht
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
take another flag and set it to true when the insert is successful and do insert only when the flag is false.Put the flag as session variable then once the page is visited and the values are inserted it won't allow to reinsert.

boolean flag=session.getAttribute("flag");
if(flag==flase)
{
//do insert
-----
----
if(insert==true)
{
flag=true;
session.setAttribute("flag",flag)
}
}//quit
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!