Chapter 15. Web Applications and Web Services
We’re 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 or service from a regular Java program is that most of the code and logic reside on the server and the user utilizes a lightweight client or a web browser to access it. This is a very appealing model of software deployment and that is why it is spreading from interactive, browser-based, page-oriented web applications to more formal, application-to-application web services.
Most of this chapter is about the mechanics of the Java Servlet API, which is a framework for writing application components for servers, just as applets are client-side application components for web pages. The Servlet API is used in both Java web applications and in the implementation of web services. However, we’ll deal with servlets directly only in the first part of this chapter, when writing web applications to be used from a web browser. Later, when we look at application-level web services, we’ll be working with tools that shield us from this level of detail. Nonetheless, the two types of server-side applications still have things in common, including how they are deployed to the server using a Web Archive (WAR) file.
The Servlet API lives in the javax.servlet
package, a standard Java API extension, so technically it isn’t part of the core Java APIs. Similarly, the APIs used for building ...
Get Learning Java, 3rd Edition 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.