Professional Documents
Culture Documents
C S C. C O M C O N S U L T I N G • S Y S T E M S II NN TT EE GG RR AA TT I I OO NN •• OO UU TT SS OO UU RR CC I I NN GG
Agenda
The J2EE platform uses a distributed multitiered application model for enterprise
applications. Application logic is divided into components according to function, and
the various application components that make up a J2EE application are installed on
different machines depending on the tier in the multitiered J2EE environment to
which the application component belongs.
•Client-tier components run on the client machine.
•Web-tier components run on the J2EE server.
•Business-tier components run on the J2EE server.
•Enterprise information system (EIS)-tier software runs on the EIS server.
Client Tier :-- Client tier is the user interface part of the enterprise application.
This tier consists of components and containers that are helpful in
projecting information/data to the end user in a meaningful
manner.Browser based clients are one of the examples of the client tier.
Presentation Tier:-- This tier houses those components and containers that
occupy intermediate position among the tiers. Their responsibilities are :--
1. Receive requests from the components of the client tier, process the
same and then appropriately route it to the appropriate component(s) in
the business tier.
2. Receive the results from the business tier, compute an appropriate view
and route the view back to the respective client.
Business Tier:-- This tier houses the components and containers that carry
business logic crucial to the enterprise. A good Practice could be to shield
these components so that the business logic is not exposed directly to the
clients. The responsibility of this tier is to compute the business logic based on
the client request and, if necessary, apply changes to the database(s) at the
back-end. It should then report the results to the presentation tier.
Resource Tier:-- This is the logical and physical end of the tier system. This tier
supports systems and applications that deal with the enterprise
information/data. The data/information in this tier are the data that need to be
persisted. The data/information referred to in this tier is often
accessed/modified/deleted by multiple processes/threads in an enterprise
situation. It is important that this data be accessed in a transactional
environment so that the data integrity is ensured.
J2EE components are written in the Java programming language and are compiled
in the same way as any program in the language. The difference between J2EE
components and "standard" Java classes is that J2EE components are assembled
into a J2EE application, are verified to be well formed and in compliance with the
J2EE specification, and are deployed to production, where they are run and
managed by the J2EE server.
J2EE web components are either servlets or pages created using JSP
technology (JSP pages). Servlets are Java programming language classes
that dynamically process requests and construct responses. JSP pages are
text-based documents that execute as servlets but allow a more natural
approach to creating static content.
Static HTML pages and applets are bundled with web components during
application assembly but are not considered web components by the J2EE
specification. Server-side utility classes can also be bundled with web
components and, like HTML pages, are not considered web components.
Business code, which is logic that solves or meets the needs of a particular
business domain such as banking, retail, or finance, is handled by enterprise
beans running in the business tier. Figure shows how an enterprise bean
receives data from client programs, processes it (if necessary), and sends it
to the enterprise information system tier for storage. An enterprise bean also
retrieves data from storage, processes it (if necessary), and sends it back to
the client program.
The enterprise information system tier handles EIS software and includes
enterprise infrastructure systems such as enterprise resource planning
(ERP), mainframe transaction processing, database systems, and other
legacy information systems. For example, J2EE application components
might need access to enterprise information systems for database
connectivity.
J2EE Containers
Normally, thin-client multitiered applications are hard to write because they
involve many lines of intricate code to handle transaction and state
management, multithreading, resource pooling, and other complex low-level
details. The component-based and platform-independent J2EE
architecture makes J2EE applications easy to write because business
logic is organized into reusable components.
In addition, the J2EE server provides underlying services in the form of a
container for every component type. Because you do not have to develop
these services yourself, you are free to concentrate on solving the business
problem at hand.
J2EE server :--The runtime portion of a J2EE product. A J2EE server provides EJB and web
containers.
Enterprise JavaBeans (EJB) container :--Manages the execution of enterprise beans for
J2EE applications. Enterprise beans and their container run on the J2EE server.
Web container :--Manages the execution of JSP page and servlet components for J2EE
applications. web components and their container run on the J2EE server.
Applet container :--Manages the execution of applets. Consists of a web browser and Java
Plug-in running
© Copyrighton the client
CSC PLOENZKE AG together.
Design Patterns
There are many good reasons to use design patterns. Here are three:
1)They are proven. You tap the experience, knowledge and insights of
developers who have used these patterns successfully in their own
work.
2) They are reusable. When a problem recurs, you don't have to invent
a new solution; you follow the pattern and adapt it as necessary.
The goal of the MVC design pattern is to separate the application object
(model) from the way it is represented to the user (view) from the way in which
the user controls it (controller).
The Model object knows about all the data that need to be displayed. It also
knows about all the operations that can be applied to transform that object.
However, it knows nothing whatever about the GUI, the manner in which the
data are to be displayed, nor the GUI actions that are used to manipulate the
data. The data are accessed and manipulated through methods that are
independent of the GUI. The model represents enterprise data and the
business rules that govern access to and updates of this data.
The View object refers to the model. It uses the query methods of the model
to obtain data from the model and then displays the information. A view
renders the contents of a model. It accesses enterprise data through the model
and specifies how that data should be presented. It is the view's responsibility
to maintain consistency in its presentation when the model changes.
The Controller object knows about the physical means by which users
manipulate data within the model. A controller translates interactions with the
view into actions to be performed by the model. In a stand-alone GUI client,
user interactions could be button clicks or menu selections, whereas in a Web
application, they appear as GET and POST HTTP requests. The actions
performed by the model include activating business processes or changing the
state of the model. Based on the user interactions and the outcome of the
model actions, the controller responds by selecting an appropriate view.
In GUIs, views and controllers often work very closely together. For example, a
controller is responsible for updating a particular parameter in the model that is
then displayed by a view. In some cases a single object may function as both a
controller and a view. Each controller-view pair is associated with only one
model, however a particular model can have many view-controller pairs.
Applets
EJB EJB
JSP Java Beans Java Beans Enterprise
Information
Systems
EJB EJB
Java Beans Java Beans (Databases,
XML
ERP,
Legacy Systems)
Internal Clients from
INTRANET
(Browsers , Desk top
Applications etc.)
ENTERPRISE SERVICES
Applets, Javabeans WML
HTML
RMI - IIOP
1. javax.servlet package contains the generic interfaces and classes that are
implemented and extended by all servlets.
2. javax.servlet.http package contains the classes that are extended when creating
HTTP specific servlets (servlets that respond to HTML)
At the heart of this, is the interface javax.servlet.Servlet – it provides the framework for all
servlets. It defines five methods.
<<Interface>> <<Interface>>
javax,.servlet.Servlet javax,.servlet.ServletConfig
init() <<Interface>>
getIntiParameter()
getServletConfig() javax,.io.Serializable
getServletContext()
service()
getInitParameterNames()
getServletInfo()
destroy()
javax,.servlet.GenericServlet
javax,.servlet.http.HttpServlets getServletContext()
getIntiParameter()
getInitParameterNames()
doDelete( ) log()
doGet( ) getServletInfo()
doOptions( ) init()
doPost( ) getServletConfig()
doPut( ) service()
doTrace( )
service() destroy()
getLastModified()
© Copyright CSC PLOENZKE AG
GenericServlet and HttpServlet
•Java servlets do not have a main () method, which is why all servlets must
implement the javax.servlet.Servlet Interface.
•The HttpServlet class is extended from the GenericServlet class.
• The two objects that the service() method receives are the ServletRequest and
ServletResponse.
•ServletRequest Object holds the information that is being sent to the servlet.
•ServletResponse object is where we place the data we want to send back to the
server.
What happens when you extend HttpServlet – Do you implement the service()
method??
Response
GenericServlet
Client
Service( )*
Request
Web server
HttpServlet
doDelete( )
Response
doGet( )
Client doOptions( )
Service( )
doPost( )
doPut( )
Request
doTrace( )
Web server
*abstract method
© Copyright CSC PLOENZKE AG
Servlet Life Cycle
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. The service() method handles all requests sent by a client (typical role of a
client services manager).
2. It starts after the init() method has been executed.
3. The most common implementation of the service() is in the HttpServlet class
(done by extending the GenericServlet abstract class).
4. The signature of the service() is:
public void service(ServletRequest req, ServletResponse res) throws
ServletException, IOException;
5. The ServletRequest object contains information about the servlet request,
encapsulating information provided by the client. The ServletResponse object
contains the info returned by the client.
1. Another set of server side Java APIs to enhance web server functionality.
2. JavaServerPages (JSP) technology allows web developers to rapidly
develop dynamic web pages and easily maintain them.
3. JSP technology enables rapid development of web-based applications that
are platform independent and enjoy cross-web-server support.
4. Collecting data / presenting processed results to the client.
5. Java snippets can be embedded into normal HTML code.
6. Closely linked interaction with JavaBeans API.