What is J2EE ? Explain about J2EE Multi-tier architecture.
J2EE (Java 2 Enterprise Edition) is an environment for developing and deploying enterprise applications. The J2EE platform consists of J2EE components, services, Application Programming Interfaces (APIs) and protocols that provide the functionality for developing multi-tiered and distributed Web based applications.
Before reading further it is recommended to read about multi-tier architecture here.
J2EE is four-tier architecture. These consist of Client Tier (Presentation tier or Application tier), Web tier, Enterprise JavaBeans Tier (or Application server tier), and the Enterprise Information Systems Tier or the Data tier.
Two or more tiers can physically reside on the same Java Virtual Machine although each tier provides a specific type of functionality to an application. Some of the APIs of J2EE components can be used on more than one tier (i.e. XML API), while other APIs (i.e., EJB API) or associated with a particular tier. Following diagram is representing the multi-tier architecture of J2EE.
CLIENT TIER : Client tier consists of programs that interact with the user. It prompts the user for input and then convert the user’s response into requests that are forwarded to software on a component that processes the request and returns results to the client program. J2EE clients can be classified as follows
Web client is A software (usually browser) that accesses resources located on the web tier.
Ejb client can access one or more enterprise java beans that are located on the EJB tier rather than resources on the web tier.
EIS clients are the interface between users and resources located on the EIS tier.
Multi-tier clients can access components located on tiers other than the tier where the multi-tier client resides.
WEB TIER : Web tier accepts requests from other software that was sent using POST, GET, and PUT operations, which are part of HTTP transmissions. The two major components of web tier are Servlets and Java Server Pages. A servlet is a java class that resides on the web tier and is called by a request from a browser client that operates on the client tier. A servlet is associated with a URL that is mapped by the servlet container. It typically generates an HTML output stream that is returned to the web server. The web server in turn transmits the data to the client. JSP is different than a servlet depending on the container that is used. JSP uses custom tags to access the bean.
ENTERPRISE JAVA BEANS TIER OR APPLICATION TIER : Enterprise java bean is a class that contains business logic and callable from a servlet or Jsp. EJB tier contains the enterprise java beans server that stores and manages enterprise java beans. This tier automatically handles concurrency issues that assure multiple clients have simultaneous access to the same object and also manages instances of components. EJB server and EJB container is responsible for low level system services that are essential for implementing business logic.
ENTERPRISE INFORMATION SYSTEMS TIER OR DATA TIER : This tier provides flexibility to developers of J2EE applications since it include variety of resources and support connectivity to resources. It defines all the elements that are needed to communicate between J2EE application and non-J2EE software.