I'm learning Java web development and currently picture the stack like this: HTML, CSS, and JavaScript in the browser; Java, Servlets, JSP, or Java EE on the backend; Tomcat as the server; and MySQL as the database. I'm now looking at the MEAN stack, where Angular is used on the frontend, JavaScript on the backend, and MongoDB as the database. I assumed Node.js was the JavaScript equivalent of Tomcat, but Node.js is usually described as a runtime environment rather than a server. If Node.js is not itself a server, what handles an HTTP request when a browser connects to a Node application? More generally, what is the difference between a runtime environment and a server? I'd appreciate a beginner-friendly explanation and a simple mental model for how these pieces fit together.
4 Answers
Node is not limited to web servers. You can use it for command-line tools, scripts, build tools, desktop applications, and background jobs. That broad purpose is why it is called a runtime. A server is simply an application that provides a service, often by listening for network requests. Also, the single-threaded JavaScript execution model does not automatically make Node unsuitable for web applications: asynchronous I/O handles many waiting connections efficiently, and worker threads or separate processes can be used for CPU-heavy work.
Tomcat is a ready-made Java web server and servlet container. It runs on the Java Runtime Environment and provides the HTTP handling, request routing, and servlet execution that Java web applications use. The JVM or JRE is the runtime underneath it. With Node, the runtime and networking libraries come together in one installation, but you still create the application that listens on a port. Express is a popular framework for doing that, though it is not the only option.
A simple stack diagram is: operating system → runtime → application → optional framework. For Java, it might be operating system → JVM → Tomcat → your servlet application. For Node, it might be operating system → Node.js → your application, with Express layered on top if you want routing and other conveniences. Your Node application can call an HTTP API, listen on port 3000 or another port, read the request, and return a response. The browser is the client, and the program listening on the port is the server. The distinction is about roles, not necessarily separate machines or processes.
A runtime is the software that executes your program. The JVM executes Java programs, while Node.js executes JavaScript outside the browser and provides useful APIs for files, networking, timers, and other system operations. A server is a program that listens for connections, receives requests, and sends responses. You can write that server using Node.js, either with Node’s built-in HTTP library or with a framework such as Express. In that setup, Node runs the code and your application performs the server’s job.
So Node is closer to the JVM than to Tomcat, and Express or a custom HTTP program is what actually handles the web requests?

That’s why the comparison can feel confusing: Java tutorials often separate the runtime and server into different products, while Node applications commonly include the server code as part of the application itself.