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 8889221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:12:32+00:00 2026-06-14T22:12:32+00:00

In what cases is better to use DispatchActions than Action?

  • 0

In what cases is better to use DispatchActions than Action?

  • 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-06-14T22:12:33+00:00Added an answer on June 14, 2026 at 10:12 pm

    When you need many similar actions with similar form bean in the same struts module (e.g. CRUD actions to create read update delete the same object). With plain Action you’ll need 4 Struts action files with imports, headers, method signatures:

    // CreateAction.java
    package com.example.package;
    // imports and header
    public class CreateAction extends Action {
        public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
            // actual code
        }
    }
    
    // ReadAction.java
    package com.example.package;
    // imports and header
    public class ReadAction extends Action {
        public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
            // actual code
        }
    }
    
    // UpdateAction.java
    package com.example.package;
    // imports and header
    public class UpdateAction extends Action {
        public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
            // actual code
        }
    }
    
    // DeleteAction.java
    package com.example.package;
    // imports and header
    public class DeleteAction extends Action {
        public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
            // actual code
        }
    }
    

    Also you’ll need 4 action mappings in struts-config.xml (of course if you are not using annotations). But in fact they will just invoke the next layer of code (manager/DAO/etc), which is independent from web (from request/response/mapping classes) and thus testable with unit tests allowing test-driven development and code reusability. All four classes will differ only in 1-2 lines of code. The rest is boilerplate, repeating again and again.

    By adding additional parameters or reusing existing one in HTTP request (in other words: in JSP form tag) you can pack all 4 actions in one class, e.g. in EventDispatchAction:

    // CRUDAction.java
    package com.example.package;
    // imports and header
    public class CRUDAction extends EventDispatchAction {
        public ActionForward create(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
            // actual code
        }
    
        public ActionForward read(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
            // actual code
        }
    
        public ActionForward update(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
            // actual code
        }
    
        public ActionForward delete(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
            // actual code
        }
    }
    

    This requires much less boilerplate. In order to tell which action you want to perform, you can use submit buttons:

    <html:submit property="update" value="Save" />
    <html:submit property="delete" value="Delete" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Are there use cases that lend themselves better to Amazon cloudfront over s3 or
How is Lucene's ConstantScoreRangeQuery better than the old RangeQuery ? In what case should
Are there any cases in which anything more than a linear speed increase comes
I'am a little bit confused what is better to use debug or write unit
I'm converting a bunch of test cases written for use with JUnit 4+ to
Is it better (faster & more efficient) to use alloc or autorelease initializers. E.g.:
Since Servlet 3.0 asynchronous processing is supported. Would it be better, to use always
Is there any other better way to perform this operation? -- USE EXAMPLE: EXEC
Many people use spaces rather than tabs. I use both of them. Tabs at
I'm interested in use cases for netmodules in .NET. In particular, I've been looking

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.