• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

form resubmission

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

I am new to struts and new to web development.
I am using a struts based customised framework and i would like to have some suggestion from you guys.

Here is the problem.
I am using jsp,tiles and struts based framework.
when clicked on back or refresh buttons on the tool bar my page gets resubmitted with duplicate values.
To prevent this i was using saveToken(request) in my page loding part of my action and getting the token value in jsp by sesstion.getAttribute.
In my submiting part of my action i am check if(isTokenValid(request)){ resetToken(request);
This is returning false in all the conditions.
This is what i tried.Please do let me know where i made the mistake.

in my launch part of my action

MyAction

launchLogic{
saveToken(request);
System.out.println("token in diary action: "+session.getAttribute("org.apache.struts.action.TOKEN"));
// launch the page code
}
submitLogic{
if(isTokenValid(request)){
resetToken(request);
// database calls
//setting the values to form
}


in my JSP

<form name="myForm">
<%
String token = ""+session.getAttribute("org.apache.struts.action.TOKEN");
System.out.println("token in jsp page: "+token);

%>

without tokens the submission part is fine if clicked on submit button.
if clicked on back and reset button the page is resubmitting with duplicate values.
My form is in session in action mapping.

Thank you for your time and suggestions in advance.

-regards,
Priyavedan
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.
 
Priya Vedan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry was new to this forum..just figured out i posted in the wrong topic
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use Token Interceptor.
 
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Make sure that you read this article regarding the Post Redirect Get.
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
May this link help.


and Michal, the OP is talking about Struts 1.x.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic