The secret's out: Java TM technology isn't just for programming applets which run on the client side in web browsers, or for writing Internet applications. The simple, flexible Servlet API brings the power of Java to your servers, too.
Java is a great platform for writing the server side of your web-based application. The same features which make Java a better platform for writing client applications make it better for writing servers. Your server applications will benefit from its type safety and other rapid development features even more than your client applications did, because multithreading support is built into the Java platform.
Java makes it easy to develop and deploy all parts of a professional, maintainable distributed system application. The Servlet API provides you the fastest way to start using Java Server technology in your network applications. You can start with applications which involve clients and a single server, and gradually create multi-tier enterprise applications which integrate the power and flexibility of Java throughout your existing network . . . because Java Servlets run on the software and hardware you've already installed.
Overview of Java Servlets
Servlets are protocol- and platform-independent server side components, written in Java, which dynamically extend Java enabled servers. They provide a general framework for services built using the request-response paradigm. Their initial use is to provide secure web-based access to data which is presented using HTML web pages, interactively viewing or modifying that data using dynamic web page generation techniques.
Since servlets run inside servers, they do not need a graphical user interface. Otherwise, they are the server side counterpart to applets (which are used only on the client side of systems): they are Java application components which are downloaded, on demand, to the part of the system which needs them.
Figure 1 Clients talking to Java Servlets in servers. Clients may range in complexity from simple HTML forms to sophisticated Java applets. Servlets will frequently use some kind of persistent storage, such as files or a database.
Servlets are most often provided by organizations which provide customized multi-user services to their customer bases. However, servlets are also flexible enough to support standardized services such as serving static web pages through the HTTP (or HTTPS) protocols, and proxying services. Since they are used for dynamic extensibility, they may be used in a plug-in style, supporting facilities such as search engines and semi-custom applications. Servlets also provide a strong platform for semi-custom applications, such as web-based order entry or inventory systems.
Although all servlets are written in Java, their clients may be written in any language. When servlets are used in the middle tiers of distributed application systems, they can in turn be clients to other services, written in any language. For example, servlets can use JDBC TM to contact an application's highly tuned relational databases. Communicating with other kinds of current or legacy systems may call for alternate software packages, as required by those systems.
Many Ways to Use Servlets
A few of the many applications for servlets include:
|A simple servlet can process data which was POSTed over HTTPS using an HTML FORM, passing data such as a purchase order (with credit card data). This would be part of an order entry and processing system, working with product and inventory databases and perhaps an on-line payment system.|
|Since servlets handle multiple requests concurrently, the requests can be synchronized with each other to support collaborative applications such as on-line conferencing.|
|One could define a community of active agents, which share work among each other. The code for each agent would be loaded as a servlet, and the agents would pass data to each other.|
|One servlet could forward requests other servers. This technique can balance load among several servers which mirror the same content. Or, it could be used to partition a single logical service between several servers, routing requests according to task type or organizational boundaries.|