File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

form resubmission

 
Priya Vedan
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry was new to this forum..just figured out i posted in the wrong topic
 
Mike Cobelmach
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use Token Interceptor.
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure that you read this article regarding the Post Redirect Get.
 
Sagar Rohankar
Ranch Hand
Posts: 2904
1
Java Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May this link help.


and Michal, the OP is talking about Struts 1.x.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic