I have a web service written in Java using Struts2, struts controller returns jsp pages, now I want to rewrite frontend using react ponents, what is the best way to start?
I have a web service written in Java using Struts2, struts controller returns jsp pages, now I want to rewrite frontend using react ponents, what is the best way to start?
TLDR, you can easily announce to your stakeholders, that it'll take few months/year or more depending on how big is your application/team.
This is huge shift from web application architecture point of view. Struts2 + JSP is doing HTML templating on back-end. So data are injected into HTML on server and HTML is also format that is returned from server.
On the other hand, React is client-side HTML templating library. So it is expected to municate with server via AJAX calls and reading data (in JSON or other format) and inject that data on client using React.
So this will not be easy change. You would need to decouple all your JSP data inject points into services and expose them as JSON data via controllers (taking into account changing of authentication mechanism, input validation, ...). After that refactoring you can start moving your JSP templates into React (most probably JSX). But on that path you realize that you may want to use some UI state management (e.g. Redux). You also discover that you want to structure your ponents into more posable way than most of old JSP templates were. Didn't mention you'll need to also port over some JS that was embedded into these JSPs. Said that, you may end up wiping out all the JSPs altogether and creating UI application from scratch.
You will also discover on that journey stuff like JS testing, UI build pipeline, asset bundling and more goodies of modern UI web development, which will add to overall refactoring.