aspose file tools*
The moose likes Struts and the fly likes form resubmission Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "form resubmission" Watch "form resubmission" New topic
Author

form resubmission

Priya Vedan
Greenhorn

Joined: Aug 17, 2009
Posts: 11
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

Joined: Jan 10, 2002
Posts: 61652
    
  67

Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Priya Vedan
Greenhorn

Joined: Aug 17, 2009
Posts: 11
sorry was new to this forum..just figured out i posted in the wrong topic
Mike Cobelmach
Greenhorn

Joined: Jun 17, 2009
Posts: 19
You can use Token Interceptor.
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

Make sure that you read this article regarding the Post Redirect Get.


SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

May this link help.


and Michal, the OP is talking about Struts 1.x.

[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: form resubmission