Deploy React Applications in a Servlet Environment


Modern web applications using React and other frameworks are often distributed as static websites. It is undoubtely the simplest, cache-friendly and dead-cheap solution. However, some enterprisey projects (think about data-entry and legacy business applications) need to be deployed in a constrained environment like a Java JEE Servlet Engine (Tomcat, Jetty, Resin) or a full-fledged Application Server (Weblogic, JBoss / WildFly, Websphere).

Forget having your app deployed on a separate “lightweight” web server like Apache or Nginx, let alone a dedicated 3rd-level domain or IP address like! These new requirements can easily interfere with the standard toolchain of the so-called React boilerplates, slowing down development and discouraging developers.

In this article we will see a solution that enables frontend developers to:

  • bootstrap applications using create-react-app
  • pack and deploy them in a Servlet Engine, even under a relative context path
  • enable the use of HTML5 History Push API with React Router
  • keep the modification to code base substantially intact

All this while preserving development speed!

Read More →