• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Problem of resubmisson in struts2

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am facing a problem of resubmition in struts. I had filled a page and submitted it. its is gone to my db and agin redirected to the same page . All data that i previously entered is filled in those fields. and if i am ginve refresh by right clicking the broswer the last trasaction agin happening and the page get submitted. HOw can i resolve this page
 
Sheriff
Posts: 9709
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well Struts 2 has the token interceptor to handle this. You just have to configure it into your action, and use <s:token/> tag in your form which gets submitted. I saw somewhere on the internet that you might need to add this type of result to your action

 
biny panackal
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Action to the page through with i am Listing data [blgCreateQuestionCategory page is used]
The same page also have an input box to enter the value and a submit button



Action to insert the value. after inserting i am rediectint to the same action that also redirect to same page
then i am refreshing the page the "InserQuestion" is happening aging

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't really figure out what you're trying to say, but am quite suspicious of the action chaining. There's almost *never* a reason to do action chaining. If you're on the page that chained to the "ListQuestionCategory" action and refresh the page you'll re-submit--the chain isn't a new request.

You might want to look up the post-redirect-get (or whatever it's called) for why it happens and some ways to avoid it.
 
biny panackal
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wht i want to do is..
I had page which displays list of category. and i have a text box and a submit button to insert new category
i have an insert method inside my action class through wich i am insring the new entry. so on the submit button click i am calling that method. But i am filling the list that need to be show in the page is in exec method. So when i am calling the insert method and dircting to the same page it wont lits those which i inserted
 
biny panackal
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now i changed my code like this

Action




Struts.xml



Now the text box get cleared and my on refresh its agin getting submitted



JSP


<s:form >
<s:textfield name="qstCategory" label="Enter Question Category"/>
<s:submit action="InserQuestion"/>
</s:form>

<DIV style="border:1px solid white; float:left;">

<s:iterator status="stat" id="qstCategoryList" value="qstCategoryList"> <s:if test="%{(#stat.index%2)==0}"> </s:if> <s:else> </s:else> </s:iterator>
<s:property value="value"/> <s:property value="value"/>

</DIV>





waiting for a solution
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And I'm telling you that you'll need to use the post-REDIRECT-get pattern to avoid the issue.

If the last request made is a redirect-get if you refresh you'll just get the same page--the one without the form submission.

Or you can use <s:token> and all that, but IMO the PRG pattern is simpler.
reply
    Bookmark Topic Watch Topic
  • New Topic