2

This is more of question of if it makes sense to use Reactjs in my instance. I have an application that generates html serverside. I can not use any js based templating solutions serverside, it is a java/jsp solution blackbox.

Since the markup is already defined I am weary of using JSX to duplicate all the template logic currently only on the serverside. What is typically the best approach to integrating reactjs in to an application like this.

What will be the real advantage to using reactjs for me in this situation. Most of may app will continue to be rendered serverside go forward.

1
  • You can render React serverside. But... React is for client-side apps. Unless you're doing at least somewhat-rich client-side interactions there's little point. Commented May 30, 2017 at 19:34

1 Answer 1

1

Obviously React is not designed to be used like this; but you could still do it.

Long story short: If you want to build something more complex in front-end you should do it; if you only want to get advantage of JSX templating instead of jsp, it's just a big overhead.

Advantages:

  • You will be able to step away from standard jQuery approach of handling javascript in .jsp.
  • You will get all the benefit of a client-side framework, so you are able to handle more complex scenarios in front-end as you would do with standard javascript.
  • You could hide some business logic in the java side (servlets) and making it available to React world.

Disadvantages:

  • Probably it's a pain to prepare the development environment mode (webpack, hot-reload, etc.); e.g. you'll need to recompile the jsp on the fly on every js change.
  • You can't use client-side routing (so you'll have like one SPA per page).
  • Probably it's really hard to make server side rendering work (for the React part)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.