Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

submit buttons in form

 
ben oliver
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a jsp form looking like --

<s:form action="saveData">
.....

<s:submit value="save" action="saveData" name="submit"></s:submit>
<s:reset value="reset" name="reset"></s:reset>
<s:submit value="display" action="displayData" name="display"></s:submit>

</s:form>

I find that when I click the first button (save) the URL shows the /saveData.action.
But when I click the second button, I still see URL as /saveData.action, but the interesting thing is when I click the second button it is actually doing the right thing, which is displaying the data. I thought it is because I put the buttons inside the form and in the <form> attribute I already defined action="saveData". So I tried removing action="saveDat" in the <form> tag. After I did that, two buttons still did what are supposed to do. But when I clicked the first button it still saved Data but the URL shows the /displayData.

How can I insure that clicking the two buttons can both do the right logics and see the correct (desired) URL ?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The URL that's displayed depends on the result configuration--if you're just doing a dispatch the URL won't change.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic