×
☰ See All Chapters

Java Enterprise Edition (JEE)/J2EE Tutorial

What is Java 2 Enterprise Edition (J2EE)?

An enterprise means a business organization and enterprise applications are those software that facilitate various activities in an enterprise. J2EE is a platform for building server side applications. JEE and J2EE are same, number 2 is removed from J2EE in JEE 1.5 version. Servlet, JSP (Java server page) and EJB (Enterprise java bean) are the main JEE APIs to create JEE application. You may hear or might have heard about frameworks or technologies like Struts, JSF, and Spring etc.…, are used to develop JEE applications. This is true, but finally all these technologies uses base technologies like servlet, JSP, EJB in their APIs to create JEE applications.

JEE Server

A JEE server is a run time infrastructure for hosting and managing JEE applications.  JEE server is having the implementation of JEE specification set by SUN/Oracle. All JEE server vendors do this implementation.  Instance of a class is called as objects; same like this instance of servlet, JSP, EJB are called as servlet component, JSP component and EJB component respectively. Objects are executed inside JVM, JEE components are executed inside an infrastructure know as containers. Ideally these containers use JVM itself to execute servlet and JSP components and Servlet and JSP components are also java objects. However in JEE, component and containers terminologies are used, this is because, container does more tasks than a JVM does. Components are more sophisticated than just an object. There are two types of JEE server:

    1. Web server: contains only web container  

    2. Application Server: contains both web and EJB container. 

Web Server

App Server

Doesn’t support EJB components

Support EJB components

Web server has Servlet and JSP containers

App server has Servlet, JSP and EJB container.

Services are limited HTTP protocols.

Services are not limited HTTP protocols. Supports other protocol support such as RMI/RPC

Example : Apache Tomcat

Example: Jboss, Weblogic

 

jee-tutorial-0
 
jee-tutorial-1
 

Components

A component is an individual Java object (class or JSP ) or an archive of related Java objects. Components are the fundamental building blocks for J2EE and come in three flavors:

1. Web components such as JSPs, Servlets, or Web Archives.

2. EJB components, which are Java Archives containing EJB code and the deployment descriptor.

3. Client applications, which are stand-alone Java executable.

Archives

An archive is a package of Java code that contains one or more specific descriptors and a manifest. Deployment descriptors are the heart of the J2EE packaging specification. Descriptors provide configuration information, environment settings, role-based security, and vendor-specific information. The manifest is a packing slip that is automatically generated by the archive process.

J2EE defines three types of archives:

  1. Java Archives (JAR)—A JAR file encapsulates one or more Java classes, a manifest, and a descriptor. JAR files are the lowest level of archive. JAR files are used in J2EE for packaging EJBs and client-side Java Applications.  

  2. Web Archives (WAR)—WAR files are similar to JAR files, except that they are specifically for web applications made from Servlets, JSPs, and supporting classes.  

  3. Enterprise Archives (EAR)—An EAR file contains all of the components that make up a particular J2EE application. 

Containers

The container is an independent application that creates an environment for components. The J2EE platform consists of various components and services that are available and operate in the following containers:

  1. Applet container  

  2. Application client container  

  3. JSP container  

  4. Servlet container  

  5. Web container  

  6. EJB container  

The container provides several key functions:

  1. Life cycle management for components. The container instantiates new instances of a component and cleans up when the component dies.  

  2. Environment configuration. The container provides configuration information and the framework for the components.  

  3. Resources. The container also provides access to enterprise information systems such as databases, naming and directory services, and e-mail systems. This access is managed through connectors. 

Transmission Protocols

The success behind client-server architecture is the ability of both parties to communicate and transfer data over a network. Transmission of data can be done by using following protocols:

  • IP: Internet Protocol 

At the lowest level, data is transmitted by using Internet Protocol (IP). There are two main points you need to know about IP. First, the packets are a fixed size, and second, delivery is not guaranteed delivery. If a packet fails, the protocol will not try to resend the data

  • TCP: Transmission Control Protocol 

Transmission Control Protocol (TCP) guarantees that the information will be delivered, and in the order it was sent, without errors. If a failure occurs, this protocol ensures the sender that it will make several more attempts at delivery. In addition, the size of the information being transferred can vary.

  • HTTP:Hypertext Transfer Protocol  

    1. HTTP was built in conjunction with HTML to enable users to access information through a web browser 

    2. Hypertext Transfer Protocol (HTTP) utilizes TCP, but adds a few more custom features. 

    3. HTTP is a stateless protocol: meaning its data is not retained from one request to the next. After a request is made, the connection is closed. Because clients are not holding open connections to a server, the server can have more clients connect over a long period of time. 

In HTTP, it's always the client who initiates a transaction by establishing a connection and sending an HTTP request. The server is in no position to contact a client or make a callback connection to the client. Either the client or the server can prematurely terminate a connection.

 


All Chapters
Author