8.3.2 Java EE 8 APIs
In this section, we will give a brief summary of the most popular technologies required by the Java EE platform and the APIs used in Java EE applications.

FIGURE 8.37 Java EE server and containers.
8.3.2.1 Enterprise Java Beans API Technology
An Enterprise Java Beans component, or enterprise bean, is a body of code with fields and meth-ods to implement modules of business logic. You can think of an enterprise bean as a building block that can be used alone or with other enterprise beans to execute business logic on the Java EE server.
There are two kinds of enterprise beans: session beans and message-driven beans. A session bean represents a transient conversation with a client. When the client finishes executing, the session bean and its data are gone. A message-driven bean combines features of a session bean and a mes-sage listener, allowing a business component to receive messages asynchronously. Commonly, these are JavaMessage Service (JMS) messages. Refer to Figure 5.58 in Chapter 5 to get more detailed information about the EJB.
In the Java EE 8 platform, new enterprise bean features include the following:
1) The ability to package local enterprise beans in a. WAR file.
2) Singleton session beans, which provide easy access to shared states.
3) A lightweight subset of Enterprise Java Beans functionality that can be provided within Java EE Profiles such as the Java EE Web Profile.
8.3.2.2 Java Servlet API Technology
A Servlet is a class defined in Java programming language, and it is used to extend the capabilities of servers that host applications accessed by means of a request-response programming model. Although Servlets can respond to any type of request, they are commonly used to extend the appli-cations hosted by Web servers. For such applications, Java Servlet API technology defines HTTP-specific Servlet classes.
The javax.servlet and javax.servlet.http packages provide interfaces and classes for writing Servlets. All Servlets must implement the Servlet interface, which defines life-cycle
methods. When implementing a generic service, you can use or extend the GenericServlet class provided with the Java Servlet API. The HttpServlet class provides methods, such as doGet() and doPost(), for handling HTTP-specific services.
The life cycle of a Servlet is controlled by the container in which the Servlet has been deployed.
When a request is mapped to a Servlet, the container performs the following steps.
1) If an instance of the Servlet does not exist, the Web container
a. Loads the Servlet class.
b. Creates an instance of the Servlet class.
c. Initializes the Servlet instance by calling the init() method.
2) Invokes the service method, passing request and response objects.
If the container needs to remove the Servlet, it finalizes the Servlet by calling the Servlet’s destroy() method.
You can monitor and react to events in a Servlet’s life cycle by defining listener objects whose methods get invoked when life-cycle events occur. To use these listener objects, you must define and specify the listener class.