Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React.js server side rendering with Java [without Node.js]

We have an application in pure JSP/JQuery which we are trying to move to ReactJs for maintainability. One of the benefits of ReactJs I am seeing is server side rendering. However, all the examples I have seen of server side rendering utilize Node.js as a server side. We are currently using Tomcat and not so much inclined to deploy node.js just for server side rendering.

I have considered few alternatives such as using Nashorn (http://winterbe.com/posts/2014/04/05/java8-nashorn-tutorial/)

However, Nashorn doesn't seem to be production ready.

Has anyone deployed React.js with server side rendering on Tomcat on production?

like image 855
Madhur Ahuja Avatar asked May 13 '16 06:05

Madhur Ahuja


1 Answers

Trying to render a Javascript app serverside without NodeJS is an excellent way to torture yourself. Trying to run javascript inside a jvm is even worse. I would recommend against it.

It is possible to render the complete client server side using PhantomJS (which technically runs without Node) or even using xvfb and Chrome on *nix. All have been done, with various degrees of painful debugging.

Running the javascript inside tomcat itself is rather unusual… I can't see the point other than "because we can". My best guess is that nobody is doing that in production.

like image 86
iwein Avatar answered Oct 08 '22 13:10

iwein