i

JAVA Complete Course

Web and Business Components

J2EE is a standard which defines the collection of frameworks to build almost every kind of business application. These can be everything started from simple web pages to the distributed systems. Application components, which are the core of enterprise systems, are built on the top of this framework.

J2EE component framework is infrastructure which is limited to only basic principles—in form of libraries, base classes, and interfaces. Application components such as business logic and presentation/controller logic are built over them.

To define the terminology, we call component infrastructure provided by J2EE as an application framework and any code or another component written on these is called as application component. But in general these two terms are interchangeable.

Previously we covered layered architecture types. J2EE Components are available on every layer. It can be used on Client Tier, Business Tier and Presentation Tier.

Client Tier components are applets and JavaBeans

Presentation Tier components are Servlets, Java Server Pages (JSP) and JavaBeans

Business Logic Tier contains only Enterprise JavaBeans.

It is critical to remember that normal Java POJO classes and Jar files can be hosted on all of these tiers without any problem. Because of Enterprise Information System (EIS) encompasses all enterprise backend resources such as databases, BackOffice/legacy systems, and ERP implementations, in the J2EE realm, components are not available for the Enterprise Information System (EIS) tier. Our needs to access to these resources from our application components, are taken care of by J2EE enterprise services. Because of this, there is no scope for application components in the EIS tier.

To achieve the reusable and good design of architecture, first of all we need well-defined roles for every component. Component interfaces assume that they follow the common standards and rules which then will be the reason of being them easily interchangeable.

All application components should be loosely coupled to achieve the flexibility across the tiers and be reusable while communicating each other. A big range of enterprise services—such as messaging, transaction processing, mailing, database connectivity, and mailing—are available at the disposal of application components.

At the end let’s shortly review some of the components of J2EE:

Enterprise JavaBeans (EJB) – This is the component technology which helps the developer to create the business object in the middle layer. These business objects are called Enterprise Beans and they consist fields and methods which perform business operations. It is also possible that instead of performing business operations by themselves, they will forward it to another bean.

JavaServer Pages (JSP) - is a text-based document interspersed with Java code. JSP text into Java Servlet code is translated with a JSP engine. After that it will be compiled dynamically and executed. This component allows us to create dynamic web pages in the middle tier. JSP pages contain static templates (HTML, WML, and XML) and elements which are used to determine how a page should construct dynamic content.

JavaMail - JavaMail API is an API on the presentation and middle layers which allows us to send and receive e-mail. This API has a service provider interface and an application-level interface for application components in order to send mail. JavaMail allows J2EE components to send and receive emails with different protocols.