Guide to Learning Java Enterprise Edition

Introduction to Java Enterprise Edition

Enterprise Java is a high scale and reverse platform that is used to develop everything from small business websites to a company's back-end system. In fact, thousands of your favorite websites are running this ever-evolving platform. Let's now look at the architecture of the application.

Java Enterprise Edition Architecture

Java Enterprise Edition architecture is a component-based and an independent platform which makes it easy to write applications. The large box labelled Java EE in the picture represents the Java Enterprise Edition platform which is the run-time environment of a Java Application Server and this is called a container. 

The Java EE container its self is made up of two other containers,

  1. Web container 
  2. Enterprise Java Beans (EJB) container.

Web container is a part of Java EE environment which runs the web components in a Java EE application that include web pages, Java servlets, and other Java EE web components that acts as an interaction between clients and Java EE applications with the use of web protocols.

The EJB container is the other part of the Java EE environment which is specified to run the application logic of the Java EE application.

Java Enterprise Edition Server

Java EE server is a server which implements the applications API's with providing standard services in a standard way to the Java EE Platform. Following are some of the services provided by the server.

Communication

  1. Transfers Internet protocols to/from Web tier
  2. Access service endpoints
  3. Transfers RMI/IIOP to/from the business tier (EJB and CORBA clients)
  4. Gives messaging service for message oriented middleware
  5. Enables connectivity for RDMBs other EIS systems
Associating components with clients
  1. Locates program asset required to satisfy client's request
  2. Gives component life-cycle and multi-threading
Application security
  1. Constraints are applied when application is deployed
Shield the developer from all of the above
  1. Declares needed services in deployment descriptors for individual application or configures them the server for all applications.

Java Enterprise Edition Archive Files

Types of Archive Files 

Java classes (POJO) are packaged in Java Archive (JAR)

  1. Built by IDE or SDK jar command
  2. Optional file manifest.mf specifies main class for Java SE
  3. Can be included in other modules or deployed to utility module

Web applications packages in Web Archive (WAR)

  1. Contains HTML, Java, images, css, etc. and all web assets
  2. It contains an optional deployment descriptor file web.xml

Connectors to EIS systems are in resource archives (RAR)

  1. Exception: JDBC drivers supplied by RDBMs vendors as a JAR

Enterprise applications packages in enterpirse archive (EAR)

  1. Contains an archive for each module in EAR
  2. Contains an optional deployment descriptor file application.xml

MVC Design Pattern in Java Enterprise Edition

  1. The web browser displays user interface.
  2. EJB reside in EJB container in Java EE server
  3. Web components like Servlets and JavaServer pages reside in Web container in Java EE server.

1. Role of Servlets in MVC

Servlets are Java classes that make up the controller layer

  1. Servlets control the web navigation.

According to MVC, servlets should:

  1. Receive HTTP request and get data from user
  2. Determine whether request can be performed. For example:
  3. If log in required, is user logged in
  4. Is input valid—prepare response to inform user if not

Call appropriate components to do business logic (model)

Get results from business logic

  1. Any post-processing of results required—prepare for display
  2. Handle exceptions from model tier

Forward result to JSP or appropriate HTTP response for display

2. Role of JSP Documents in MVC

JSP, HTML and files that browsers display up the view layer

  1. Includes images, stylesheets, JavaScript executed by the browser.

JSP pages are XHTML documents plus extra tags

According to MVC, JSP pages should:

  1. Be the user interface (together with html and other web resources…)
  2. Implement the “look and feel” of the application
  3. Display HTML forms for user input
  4. Display dynamic content (results) prepared by servlets
  5. Using JSP Expression language and Java Template Library tags
  6. Submit requests for processing
  7. HTML <a href=“servlet alias” > or <form action=“servlet alias”>
  8. <a> can also link directly to other pages without invoking servlets

3. Model Layer Classes in MVC

The core business logic makes up model layer using intellectual capital of the organization creating the application

Core functionality knows nothing of user-interface or controller

  1. One model layer may have more than one user interface
  2. Changing the user interface does not affect on model
  3. Changing the model does not affect the UI unless the reason for the change is to add, remove or modify functionality

Servlet is the intermediary that connects each UI to the model

  1. Servlets must know what public methods to call on model
  2. Servlets must handle exceptions thrown by the model
  3. Servlets must know file and field names in the JSP/HTML
Now Reading
Guide to Learning Java Enterprise Edition