Search code examples
javajspframeworksstrutstapestry

Piecemeal Conversion from Struts to Tapestry 5


I have a Struts (1.3.8) application that I'd like to convert to Tapestry 5. There will probably not be time to do the whole conversion in one fell swoop. I'd like to deliver new functionality in Tapestry and convert existing Struts / JSPs as time permits. Has anyone attempted something like this? Can Struts and Tapestry co-exist?


Solution

  • Without ever using Tapestry, I'd say that any two frameworks should be able to co-exist because in the web.xml you define how the urls map to servlets/filters. For example, in Wicket there is a filter which checks for Wicket classes that implement the request handler. If nothing matches, the request is passed up the chain. This would allow you to continue to use Struts for certain actions.

    If you have some URLs that you want to preserve, you can just change the Struts action to forward to the new internal URL; eventually all your struts actions will be, essentially, url-rewriting actions, and you can just rip out struts and replace it with a url re-writing filter.

    If none of your new URLs will conflict with your old urls, then there is nothing difficult to do. Just set up the new framework and its request handlers. When a struts action is encountered (/doSomething.do) the Struts ActionServlet will dispatch the request to the action. In the struts-config.xml you can forward to the right place, either a JSP or a tile or a Tapestry URL. I imagine there is a way, in Tapestry, to forward to an arbitrary url after you're done processing a request; just forward to a Struts action if you need to.

    The one sticky problem I can foresee is if Struts and Tapestry have conflicting requirements for third-party libs. If that doesn't work you might be seriously out of luck for any kind of easy migration.