wood burning stoves 2.0*
The moose likes Struts and the fly likes duplicate form submission Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "duplicate form submission" Watch "duplicate form submission" New topic
Author

duplicate form submission

sri valli
Greenhorn

Joined: Oct 20, 2008
Posts: 20
Hi,
I am using struts framework.
i have a problem with the code which i am using.
in JSP i have a field called"surname".
when i do a search based on this it will have display the results fetching from the database.
when i click on back button in searchresultspage and come to the search page and try to search using new value it still displaying old values.
please look into the code which i am working and i added saveToken() and isTokenValid() in two different action classes.

and i am using savetoken() in the previous action class from where we get the input (previous JSP->action class)for the current search page .
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
Where does your database look up code get its query parameters from? If they come from your form bean, what is the scope of your form bean and are the old values possible still in hidden fields on the screen?

If you get them from your session object check to make sure you are keeping your session object up to date with the latest search parameters?

Posting your code that shows the relevant places where you get the parameters for you sql statement and how you believe those values are being populated.
sri valli
Greenhorn

Joined: Oct 20, 2008
Posts: 20
Thanks tom for your reply. i am getting the values to connect to the database are from form.bean only.. The problem is i am giving one value in the request and the value in the session object are different. Session object is not taking the new value what ever i am giving. once the value come to session object the way it is getting the values from database are far good. i have checked the flow using some debug statements.
I am using the TOKEN as hidden value in my JSP like the following.

<input type="hidden" name="<%=org.apache.struts.taglib.html.Constants.TOKEN_KEY%>" value="<bean:write name="<%=Globals.TRANSACTION_TOKEN_KEY%>"/>">



for any help thanks in advance.
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
I'm confused. First off, let me know the scope of your form bean when you get a chance. Second, your form bean is populated from your request. If you are getting your query data from your form bean then I'm not sure why it matters what you have in your session. Please explain how your session data is involved with your query parameters. Showing the code where you get your query parameters from might help.
sri valli
Greenhorn

Joined: Oct 20, 2008
Posts: 20
Hi Tom,

My form bean scope is session.and this from bean is used accross multiple pages in my web application.

In the my FORM i have defined the reset method to reset the values when i give a new request.

But the problem is the values are not getting reset.


first when i give a value in JSP it flows to from bean..
in form bean the old values are reset to new values when the JSP loads
and in my action i am getting the new values from form bean..from setters and getters.
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
Hi Sri, I was looking at the code for your action form in your other posting. It doesn't look like you are extendint actionForm in that class and the method signatures for the reset methods in it don't look like they match the API to me. Is this stuff that just got messed up when you were posting the code, or is this the way that you have the code that you are currently running?
sri valli
Greenhorn

Joined: Oct 20, 2008
Posts: 20
Hi Tom,
Thanks for the concern..
I have done it by mistake.


The correct method is


public void reset(ActionMapping mapping,HTTPServletRequest request){

super.reset(mapping,request);
//aray declaration
}

and one important thing is the problem of reset is not happening always..
some times it is working fine..and some tmes it is giving problem
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
In the reset method, I don't see you resetting surname. Is that also something you omitted in your posting or is this how the code is?
sri valli
Greenhorn

Joined: Oct 20, 2008
Posts: 20
HiTom,

What i believe is actionform overrieds the reset() method automatically and reset the old values with the new values.
is it not?
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
When you put a reset method in your action form it does override that reset method in the parent class. But you need code in your reset method to set the values of your properties to null. So you need the line

surname = null;

in your reset method.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: duplicate form submission
 
Similar Threads
Generating Action for multiple search option
F5 causes action to be executed again
Duplicate form submission - Synchronizer Token Pattern
form resubmission
Duplicate form submission