The moose likes Struts and the fly likes submit buttons in form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "submit buttons in form" Watch "submit buttons in form" New topic

submit buttons in form

ben oliver
Ranch Hand

Joined: Mar 28, 2006
Posts: 375
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>


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

Joined: Sep 29, 2008
Posts: 12617

The URL that's displayed depends on the result configuration--if you're just doing a dispatch the URL won't change.
I agree. Here's the link:
subject: submit buttons in form
It's not a secret anymore!