• 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

duplicate form submission

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 .
 
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Seriously Rick? Seriously? You might as well just read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic