HydraExpress Components : Servlet Development Guide : PART I Introduction : The Servlet Container and Servlet Concepts
The Servlet Container and Servlet Concepts
The Servlet Approach
The servlet API includes a set of classes for creating servlets. Its design is based on the Java Servlet API, implemented in C++.
A servlet is a component that generates dynamic content to run inside a servlet container. For HydraExpress, the container is hosted inside the HydraExpress Agent. The servlet container provides the runtime environment for the servlet. The Agent handles the details of network programming, receives and parses requests, transmits responses, and manages connections. The servlet container instantiates the servlets and maintains state. The servlet itself focuses on application logic.
The servlet container is implemented as a pluggable handler in the Agent’s handler chain. The Agent never communicates directly with the requestor (client). Instead, the Agent routes servlet requests to the servlet container. This configuration allows the Agent to manage security. The container may also serve static files related to the Web services in the container, such as WSDL definitions, XML Schemas, or HTML pages.
At first glance, a servlet may seem similar to a Web server plug-in. However, there are several important differences. The servlet API is designed to be easy to use and to encapsulate the details of handling a response. The API does not provide access to the inner workings of the Agent, but instead provides the features necessary for creating dynamic content. The servlet API is portable between Web servers and Agents, so that a servlet need not depend on a particular server or a particular platform. The servlet may run in a separate process from the server, and can even be hosted on a different machine or Web server. Finally, a servlet has access to general-purpose classes unrelated to the Agent. For example, Java servlets rely on the JDK, while HydraExpress servlets may depend on SourcePro C++.
This chapter discusses the concepts and implementation of the servlet API and the servlet container, a component of the Agent. For information on the overall Agent and its architecture, see the HydraExpress User Guide.
The HydraExpress servlet container has two distinct aspects:
*The container itself
*One or more contexts that contain servlets, filters, listeners, or named objects
Understanding these components, and the relationship between them, is key to understanding the HydraExpress’s servlet development and hosting capabilities.