# Struts 2 Result Type

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

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>


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

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


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.

struts.xml

    //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>
</result>
</action>


## FreeMaker result type

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 filename.fm.

Welcome to SPLessons
${id}${name}


FreeMaker type is defined in the struts.xml file.

<pre><action name="result" class=" Action class">
</result>
</action>


## Redirect result type

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.

<struts>
<package name="default" extends="struts-default">