Chapter 17. Deploying Clojure Web Applications

Once you’re past a certain point of competence with Clojure and are on your way toward having a working application completed, you’ll inevitably need to deliver its functionality to your users and customers. The modern era has tilted distribution norms toward server-side deployments (often “in the cloud”) that clients interact with via web services and interfaces. In this chapter, we’ll explore the various ways one can package and then deploy Clojure web applications, taking full advantage of the mature facilities that the JVM and Java ecosystem provide for doing so.[413]

Java and Clojure Web Architecture

Almost without exception, Clojure web applications are packaged and deployed as servlets, the same fundamental architecture used by web applications written in Java. Web servlets are simply Java classes that extend the javax.servlet.http.HttpServlet base class, which defines a programmatic interface for handling HTTP requests. There are methods for each HTTP request method (GET, POST, and so on), each of which accept request and response objects; each HTTP request method implementation examines the incoming request and coordinates the writing out of the response contents. Applications that follow the servlet specification (which boils down to implementing a single Java interface and following some packaging conventions) can be deployed as web applications to any of many dozens of app servers, many of which offer a variety of specialized ...

Get Clojure Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.