users@jersey.java.net

Re: [Jersey] struts to jersey app

From: Craig McClanahan <Craig.McClanahan_at_Sun.COM>
Date: Sat, 06 Jun 2009 11:26:00 -0700

paksegu wrote:
> Hi,
> Is it difficult to convert a struts app to jersey?
>
> Ransford Segu-Baffoe
>
> paksegu_at_yahoo.com
>
> http://www.noqmx.com/
> https://serenade.dev.java.net/
>
>
Trying this is going to be quite a challenge, depending on exactly how
you are using Struts. There will be lots of "intermediate" sized issues
to address, including:

* No direct support for forms the way ActionForm works
  (although you can get around that in many cases by
  processing form parameters by name in your resource classes).

* No custom tag library if you're using JSP pages
  (although things like JSTL can get you a ways
  towards this)

But the biggest challenge is that a Struts application is "action
oriented" (even down to the class names of the framework's main APIs
:-), not "resource oriented". So, the URIs of a Struts app tend to be
verbs (/listCustomers.do, /addOrder.do, etc.), not nouns like you would
see in a typical REST based app (/customers, /customers/123456,
/customers/123456/orders, etc.).

If you did a really good job of segregating your business logic into
support classes, your best bet would be to build up a new set of JAX-RS
resource classes from scratch, reflecting a REST style set of URIs, with
the resource methods accepting form parameters directly instead of using
form beans. You've still got to deal with how to build the UI, though.

If your business logic is deeply intermixed in your Struts action
classes, though (alas, quite a few Struts developers made this mistake),
you are better off thinking of this as a rewrite, not a conversion.

Craig