Implementing Servlets
Now we’re going to take a leap from the client side over to the server side, to write Java applications for web servers. The Java servlet API is a framework for writing servlets, which are application components for a web server or other type of server; just as applets are application components for a web browser.
The servlet APIs live in the
javax.servlet
package, which is a standard Java API
extension, not part of the core Java APIs. In this book we
haven’t talked about many standard extension packages, but this
is one is particularly important. (It should probably be a core API.)
You’ll want to grab the latest
Java Servlet Development Kit (JSDK)
from http://java.sun.com/products/servlet.
The servlet APIs are useless without a server on which to run them, so you’ll also want to find an implementation of the servlet environment for your favorite web server: Netscape, Apache, or whatever. We won’t try to anticipate which environment you have in this book, so the details about how to install your servlets and invoke them will be up to you. But it should be pretty easy.
Why Servlets?
Why would we want to use Java on the server side, as opposed to a scripting language, such as Perl? The simplest answer to that question is: for the same reasons that you would use Java anywhere else. Servlets simply let you write in Java and derive all of the benefits of Java and the virtual machine environment on the server side. (You also have the limitations of Java.) Historically, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access