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?

  • If it was small, it could be manageable. But if it was small, you wouldn't be asking this. May 12, 2011 at 16:36
  • Is it Struts 1 or Struts 2? Because they are almost entirely different beasts (Struts 2 used to be called WebWork).
    – Behrang
    Jun 9, 2011 at 17:46
  • @Kevin, it was already a while since you have posted this message. Have you succeed in converting the app? Maybe you have already shared your experience somehow via blogs or other posts...? I'm asking while I may have a similar project ahead. Thanks.
    – Dime
    Mar 14, 2012 at 15:25
  • 1
    @Dime: The site is currently split into two web apps: old struts app, and new Grails app. They share the database and web context. The old functionality is being reimplemented in Grails page by page. I just installed the HAML plugin and like it a lot. Mar 14, 2012 at 15:39

2 Answers 2


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>

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


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

  • @Behrand: Using Groovy HtmlBuilder, the rendering would be done by the Groovy code, and not by interpolating some data file. We use JSPs and velocity in Java because the corresponding Java code would be horrible. With a Groovy builder, there's no need to bring in another language. So I suppose my Actions could just write the response and return null. Jun 9, 2011 at 21:47
  • @Kevin, that could be possible. Also please read my updated post.
    – Behrang
    Jun 9, 2011 at 23:15
  • Great, now all I have to do is migrate from Struts 1 to Struts 2 :-) Jun 10, 2011 at 12:38
  • @Kevin, I didn't know you're using Struts 2.
    – Behrang
    Jun 11, 2011 at 3:17
  • I'm not. Jun 11, 2011 at 12:22

I'm not sure how your JSP Struts-flavored tags will be differ from Grails views.
Grails views are also about tags.

A much more important issue IMHO is the controllers themselves and your application's URLs. Basically you are going to rewrite the whole application which is going to consume a lot of time, a time you could spend on refactoring your current Struts project.

It is also worth mentioning that Grails applications tend to consume a lot of memory, I think you should think about this too.

What about your team? are they familiar with Groovy and Grails?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.