Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6564919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:01:45+00:00 2026-05-25T14:01:45+00:00

I have this code in my JSP: <%@taglib uri=http://struts.apache.org/tags-html prefix=html%> .. .. <html:form action=update

  • 0

I have this code in my JSP:

<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
..
..
<html:form action="update" >
  ..
  ..
  <html:submit value="delete" />
  <html:submit value="edit" />
  <html:sumit value="update" />
</html:form>

And this in the struts-config.xml file:

<action path="/delete" name="currentTimeForm" input="/viewall.jsp" type="com.action.DeleteProduct">
   <forward name="success" path="/viewall.jsp" />
   <forward name="failure" path="/viewall.jsp" />
</action>

Like the delete action, I have edit and update. It works fine, if I give the name specifically like <html:form action="delete"> but, how to make it dynamically work for update and edit?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:01:45+00:00Added an answer on May 25, 2026 at 2:01 pm

    You have one form and multiple submit buttons. The problems is that a form can only submit to one action, no matter how many submit buttons you have inside the form.

    Three solutions come to mind right now:

    1. Have just one action where you submit everything. Once inside the Action class check what button was used to submit the form and perform the appropriate treatment based on that.

    <html:form action="modify">
      ..
      ..
      <html:submit value="delete"/>
      <html:submit value="edit" />
      <html:sumit value="update" >
    </html:form>
    

    In the ModifyAction.execute(...) method have something like:

    if (request.getParameter("delete") != null || request.getParameter("delete.x") != null) {
       //... delete stuff
    } else if (request.getParameter("edit") != null || request.getParameter("edit.x") != null) {
       //...edit stuff
    } else if (request.getParameter("update") != null || request.getParameter("update.x") != null) {
       //... update stuff
    }
    

    2. Have the action attribute of the HTML form changed using JavaScript before submitting the form. You first change the submit buttons to plain ones with click handlers attached:

    <html:form action="whatever">
      ..
      ..
      <html:button value="delete" onclick="submitTheForm('delete.do')" />
      <html:button value="edit" onclick="submitTheForm('edit.do')" />
      <html:button value="update" onclick="submitTheForm('update.do')" />
    </html:form>
    

    With the handler:

    function submitTheForm(theNewAction) {
      var theForm = ... // get your form here, normally: document.forms[0]
      theForm.action = theNewAction;
      theForm.submit();
    }
    

    3. Use a DispatchAction (one Action class similar to point 1) but without the need to test for what button was clicked since that’s treated by the DispatchAction.

    You just provide three execute methods properly named delete, edit and update. Here is an example that explains how you might do it.

    In conclusion: For number 1, I don’t really like those ugly tests…. for number 2, I don’t really like the fact that you have to play with the action form using JavaScript, so I would personally go for number 3.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this JSP code snippet: <%@ taglib uri=http://java.sun.com/jsp/jstl/core prefix=c%> <c:choose> <c:when test=${var1.properties[\Item Type\]
I have this line of code in my JSP. (I'm using struts 1.3) <html:form
we have this example: http://code.google.com/apis/maps/documentation/v3/basics.html#DetectingUserLocation which shows how to get the user's position in
I have a code like this <html> <head>Title <script> function callme() { alert(Hi); document.test.action
I have this error when I try to include the tag ( http://code.google.com/p/struts2-jquery/wiki/HeadTag )
i have the following code from my JSP which doesn't quite work: <%@ taglib
I have this nav code in multiple JSP files: <ul id=nav> <li ><a href=/home>Home</a></li>
I have this code in my jsp <div class=controls> <input type=image class=sprite submit-button button
i have this code which is not working. <jsp:useBean id=abbreviationlist class=AbbreviationListType/> <jsp:setProperty name=abbreviationlist property=id/>
I have this simple code in facelets numbers.xhtml: <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.