Search code examples
struts2struts

Return Custom JSP in Struts 2 without a Defined Result


Is it possible to just return a custom JSP filename in a Struts action, which doesn't have a mapped Result?

Example:

public String doAction() throws Exception {
   return "myfile.jsp";
   // do not return a mapped result
   // return "success";
}

When I do so, I get the error

No result defined for action MyAction and result myfile.jsp 

The reason is I'm developing a new flow where multiple actions can lead to a new special error page. But it would be a pain to patch the entire Struts-Config XML with the new result defined for every action! So I want to avoid that and just reference a JSP directly.


Solution

  • Following Struts feature and tutorial could be used instead to solve your original issue:

    1. Global Results
    2. Exception Handling