Struts 2 Result Type

shape Description

Struts 2 Result Type are just JSP pages that map to an action, Struts 2 is supported different Result/Result Type View pages. Action class business logic is executed and the result forwarded to View pages. In Struts2, <result> tag is used in struts.xml configuration file under the action tag. Following are the types of result types and result tag will be kept in struts.xml file.

Dispatcher result type

shape Description

Dispatcher result type is the default result type. If one do not write any result type in struts.xml file, the container will go to the default pages. like JSP pages or HTML pages. It is internally called the RequestDispatcher.forward(). Action class is executed and generated the response and this response is forwarded to success.jsp page.

<result name="success">success.jsp</result>

shape Example

In struts 2 default result type is taken the dispatcher type.

<result name="success" type="dispatcher">

If one configure the success.jsp page in Web content folder, have to write the <param> tag (optional). change the success.jsp page location in Web content folder and write the <param > tag under <result> tag. <param > represent location of View pages.


    //If we are taken the success.jsp page in resource folder.
<action name="result" class=" Action class">
     <result name="success" type="dispatcher">
        <param name=" view page location">/resource/success.jsp</param>

FreeMaker result type

shape Description

FreeMaker result type is a type of view page, which generate the output using predefined templates. One can defined the result type=” free maker” ,which internally call the dispatcher.include().

If one pass the input from the browser, and that input value is set to the action class through request object. Then, the properties can be called in another FreeMakerView page using predefined templates. FreeMaker view pages saved on

shape Example

Welcome to SPLessons

FreeMaker type is defined in the struts.xml file.

<pre><action name="result" class=" Action class">
     <result name="login" type="freemaker">
        <param name=" view page location">/resource/</param>

Redirect result type

shape Description

When the defined result type is redirect in struts.xml file, then the container will call response.sendRedirect() method internally. Create the response in a new page in given location.

   <package name="default" extends="struts-default">
       <action name="login" class="LoginActionClassName" method="execute">
          <result name="login" type="redirect">


shape Key Points

  • Struts 2 Result Type – The tag is utilized to expose the view.
  • Struts 2 Result Type – Dispatcher is the default result type.
  • Struts 2 Result Type – The free maker engine uses predefined templates to get an output.