Struts to Groovy – Migrating a Struts/JSP Application

grailsgroovyjspstruts

I have taken over development of a JSP/Struts application. Right now it's a bit of a mess, and I'm finding the JSP pages with Struts tags to be insanely verbose. Has anyone migrated a Struts application to Groovy/Grails? Can it be done incrementally, page by page?

@4bu3li: I was thinking of replacing the JSPs one by one with Groovy HTML builder code. IMO struts tags are a masterpiece of verbosity and obfuscation, and I'm tired of matching open and close tags. Right now the team is just me and one other guy, and I know Groovy better than I know JSPs and Struts. We are reworking the entire site, so it's all going to be rewritten somehow. But I can't stop maintenance, so I need to incrementally rewrite it page by page. Could I just start reworking Struts action methods to return Groovy-generated content?

Best Answer

I haven't used Struts for ages, but Struts by default can render Velocity markup, FreeMarker, as well as JSP (maybe other formats too).

For example, to render FreeMarker pages, your action definitions would look like this:

<action name="test" class="com.acme.TestAction">
    <result name="success" type="freemarker">test-success.ftl</result>
</action>

I assume you should be able to use a custom type to render GSP or builder code.

UPDATE:

Here it is explained how to create Struts 2 actions using Groovy.