Chapter 15. Web Applications and Web Services
We’re now going to take a leap from the client side to the server side to learn how to write web-based Java applications and services. What distinguishes a web-based application from a regular Java program is that much of the code, logic, or data resides on the server, at least initally, and the user utilizes a web browser or a lightweight client to access it. This is a very appealing model of software deployment facilitated by the increased standardization and power of HTML and JavaScript in web browsers as well as higher-speed Internet connectivity and better application-to-application web service standards.
Most of this chapter is about the mechanics of the Servlet API, which is a Java framework for writing application components for servers. The Servlet API is used in both Java web applications and often in the implementation of application-to-application web services. We’ll deal with servlets directly in the first part of this chapter, when writing examples used from a web browser. Later, we’ll look at application-level web services that are designed to provide data and services to all types of client applications in a more behind-the-scenes fashion. The two types of server-side applications have some things in common, including how they can be deployed to an application server using a Web Archive (WAR) file and the fact that they are often combined in advanced applications that both render pages on the server and use JavaScript ...