JSP Tag Libraries

Скачать в pdf «JSP Tag Libraries»
2.2.1 The servlet API and programming model


Extending the web server with a Java servlet consists of four steps:


■    The developer provides a servlet class that obeys the servlet API (presented later in this section).


■    The server administrator deploys the servlet in a web container (a web server that knows how to handle servlets) and informs the container which requests should be handled by the servlet (e.g., any request URI suffixed with .jsp should be forwarded to the JSP servlet).


   When a request arrives, the web container checks the request URI against the servlet mappings and invokes a servlet, if needed.


■    The servlet takes over the request and serves it.


NOTE The term web container evolved out of an attempt to harmonize the terms used in Java 2 Enterprise Edition (J2EE). A web container is the runtime environment in which servlets operate; the container is responsible for the instantiation, initialization, execution, and termination of the servlets. There are other names for the servlet runtime environment; the most common of which is servlet engine. Think of a web container as a web server with servlet support.


As developers, we will concentrate on how the servlet API and the servlets themselves look. Later sections will present a way to configure the web container in a cross-server fashion.


The servlet API defines:


1    How the servlet appears to the web container and its life cycle


2    What services the web container renders on the servlet’s behalf


3    Container-neutral application bundling

Скачать в pdf «JSP Tag Libraries»