Lesson 9 | Technology of Java Servlets |
Objective | Technology behind Java Servlets |
Technology behind Java Servlets
Describe the technology that makes servlets work. Any Java program starts by defining a class?
An applet is written if your class extends
java.applet.Applet.
One might assume that you are writing a servlet if your class extends
java.servlet.Servlet
however, that is not correct.
First of all, servlets are not part of the Java 2 SE and are an extension to Java.
So the full name of the servlet class starts with javax, not java. But more importantly, there are several kinds of servlets. The ones we have talking about in this module, and will talk about for almost the entire course, are HTTP servlets, which work with a Web (HTTP) server such Tomcat, Apache, and Websphere.
Dynamic Content
Shortly after the Web began to be used for delivering services, service providers recognized the need for dynamic content.
Applets were one of the earliest attempts toward this goal and focused on using the client platform to deliver dynamic user experiences.
At the same time, developers also investigated using the server platform for the same purpose.
Initially, (CGI) Common Gateway Interface server-side scripts were the main technology used to generate dynamic content.
Although widely used, CGI scripting technology had many shortcomings, including platform dependence and lack of scalability.
To address these limitations, Java Servlet technology was created as a portable way to provide dynamic, user-oriented content within the context of server-side technologies.
But at the moment, it is HTTP servlets for us. One is writing a servlet when one writes a class that extends
javax.servlet.http.HttpServlet
When an applet runs, the Web browser calls many of its methods.
Some are inherited untouched from the superclass, java.applet.Applet, and some are overrides that you have written.
It is the same with servlets: the Web server starts the servlet running and calls many of its methods.
In the next lesson, the one method almost all servlets override will be discussed.