You are on page 1of 37

HTTP Overview

What is Http? - Http is a protocol that runs on top of TCP/IP TCP: It is responsible for making sure that a file sent from one network node to another ends up as a complete file at the destination, even though the file is split into chunks when it is sent IP: It is underlying protocol that routes the chunks (packets) from one host to another on their way to the destination

HTTP is the protocol clients and servers use on the web to communicate
HTTP defines the requests that a client can send to a server Each request contains a URL, which is a string that identifies a Web component or a static object such as an HTML page or image file.

Http Requests
An Http request consists of a request method, a request URL, header fields and a body HTTP 1.1 defines the following methods Get: Retrieves the resource identified by the request URL Head: returns the headers identified by the request URL Post: sends data of unlimited length to the web server Put: Stores a resource under the request URL Delete: removes the resource identified by the request URL Options: returns the Http methods the server supports Trace: returns the header fields sent with the request

Http Responses
An Http response contains a result code, header fields and a body Some commonly used status codes include: 404: Indicates that the requested resource is not available 401: Indicates that the request requires HTTP authentication 500: Indicates that an error occurred inside the HTTP server that prevented it from fulfilling the request 503: Indicates that the HTTP server is temporarily overloaded and unable to handle the request

Summary of status codes


1xx indicates an informational message only 2xx indicates success of some kind 3xx redirects the client to another URL 4xx indicates an error on the clients part 5xx indicates an error on the server part

Placing the Java EE Model in Context

Requirements of Enterprise Applications


The Java EE platform: Is an architecture for implementing enterprise-class applications Uses Java and Internet technology Has a primary goal of simplifying the development of enterprise-class applications through an application model that is:
Vendor neutral Component based

Java Technology Platforms

Java technologyenabled devices

Java technologyenabled desktop

Workgroup server

High-end server

Micro Edition

Standard Edition

Enterprise Edition

Enterprise Application Infrastructure Technologies


Single-User Business Application Enterprise Infrastructure Requirement User authentication Multi-user support Data integrity Client-tier communications Technology or Domain Multiuser Enterprise Applications

Security domain technologies Persistence technologies Transaction technologies Networking and distributed object technologies Messaging, connector and related technologies

Communication with other enterprise and legacy applications Service location assistance

Naming service technologies

Java EE Technology Suite


Application Components Email Servlets and JSP Pages JMS API Web Services Entity Classes Java SE EJB Components JNDI API, RMI, CORBA, SQL, JTA JAX-WS Connectors JMX Specification Integration

ebXML

Declarative Transaction Management Declarative Security

Container Management

Java EE Specifications and the Java Community ProcessSM

Java EE EJB Component Servlet

Java Community Process

Specifications and APIs

Developers

Component, API, and Service Layer


Component Layer Vendor neutral

API Layer

Defined by the Java EE specification (vendor neutral)

Service Layer

Vendor specific

Databases and other back-end services

Java EE Component Containers

Embedded EJB Container Web Container Application Client Container EJB Container

Database

Separation of Business Logic from Platform Services


Developers Checklist Business services Persistence Transaction management Multithreading Security management Build from the ground up Networking Service publishing Developers Checklist Business services Services Provided by Server Persistence and Transaction management Multithreading Security management Use Application Component Server Networking Service publishing

JavaMail Java Persistence JTA Connectors JMS EJB Container WS Metadata EJB

Web Services
Web Beans JACC JASPIC JAXR JAX-RS JAX-WS JAX-RPC New in Java EE 6 SAAJ Java SE Java Persistence Application Client Container Application Client

Java EE Service Infrastructure

JavaMail JSTL JSF Java Persistence JTA Connectors JMS Management WS Metadata Web Services Web Beans JACC JASPIC JAXR JAX-RS JAX-WS JAX-RPC

Web Container

JSP

Servlet

HTTP SSL

HTTP SSL

SAAJ

Database

Java SE

Management

Applet Container

Java SE

Applet

SAAJ

Java SE

N-Tier Architectural Model

Client Tier

Presentation Tier

Business Tier

Integration Tier

EIS/Data (Resource) Tier

The N-tier architectural model: Programmatically separates application functionality across three or more tiers Has tier components and tier infrastructure that is uniquely suited to a particular task Has programmatic interfaces that define the tier boundaries

Java EE-Tiered Architecture

Client Tier

Presentation Tier

Business Tier

Integration Tier

EIS/Data (Resource) Tier

Web Browser HTML Form HTTP

Web Container Controller RMI/IIOP

EJB Container Business Services Entities

DBMS SQL

UI Client

Views Presentation Business Resource

Java EE Application Boundary

Java EE Application Architecture


Web-centric architecture Combined web and EJB componentbased architecture, sometimes called EJB componentcentric architecture Business-to-business (B2B) application architecture Web service application architecture

Java EE Web-Centric Architecture

Web Browser HTML Form HTTP

Web Container Controller

EJB Container DBMS Business Services Entities SQL

UI Client

Views

Model Resource

Presentation and Business

The introduction of EJB Lite in Java EE 6 allows the use of some EJB technology in web-centric architectures.

Java EE EJB ComponentCentric Architecture

Web Browser HTML Form HTTP

Web Container Controller RMI/IIOP

EJB Container Business Services Entities

DBMS SQL

UI Client

Views Presentation Business Resource

Java EE Profiles
Java EE 6 standardized profiles for application developers that do not need the full Java EE platform but require application portability. Developers can choose between:
The Java EE 6 Web Profile: Similar to Tomcat, when developers are working primarily on web applications The Java EE 6 Full Platform: Complete Java EE 6 application servers

Technically Full Platform is not a profile. The only profile included in the Java EE 6 specification is the web profile. Additional profiles may be added in future releases.

EJB 3.1 Lite


The Java EE 6 Web Profile includes support for Enterprise JavaBeans (EJB) 3.1 Lite. EJB 3.1 Lite:
Is a subset of the EJB API Allows local session beans Enables EJB usage in Java EE Web-Centric Architectures Is supported in web containers and Java SE applications with an embedded EJB container

EJB 3.1 Lite is covered in more detail in the lesson titled EJB Component Model.

B2B Application Architecture

Web Container

EJB Container

Java EE Server

Web Container

EJB Container

Java EE Server

EIS Resources

Java EE Web Service Architecture


Web Container Service Endpoint Interface

POJO

Java EE Application Server


Web Service Client EJB Container Service Endpoint Interface Stateless Session Bean

Web Service Requester

Java EE Application Server

Java EE Patterns
Patterns provide a standard solution for well understood programming problems. The Java EE pattern catalog:
Helps a developer create scalable, robust, high-performance, Java EE technology applications Presupposes the use of the Java programming language and the Java EE technology platform Is, in many places, closely related to the Gang of Four (GoF) patterns

Java EE Pattern Tiers

Java EE Patterns

GoF Patterns

Presentation Tier Business Tier Integration Tier

Creational Structural Behavioral

Architectural Principles

Design Principles

Using Java EE Patterns

View JSP Page View Helper

Controller Service Locator Business Delegate

Model Session Facade

Session

Entity

DAO

JNDI API

Java EE BluePrints
Developed by the Java software group Provide a set of guidelines and a sample application Used as a reference when designing and developing a Java EE application or Java EE application components Known as the Java BluePrints Solutions Catalog for Java EE

Model 1 and Model 2 Architectures


Two design strategies are involved in using JSP components in the web tier: Model 1 architecture:
JSP components handle request processing through <jsp:useBean> classes, the JSTL, and custom tags. JSP components render data that is retrieved from the business logic tier.

Model 2 architecture:
Servlets handle request processing, interact with the business logic, and collect data for display. JSP components render the data for display.

Traditional MVC Architecture

Model Updates model Notifies changes Retrieves data Sends events View Sends data Controller

Selects view

Model 2 Architecture as MVC

Model Classes or Components

Updates model

Renders data Sends events Selects view Sends data

Retrieves data

View JSP Components

Controller Servlet

MVC in the Java EE Platform


The MVC paradigm divides application logic into three roles: Controller View Model
When the application includes EJB components When there are no EJB components

Using Web-Tier Design Patterns


The web-tier developer should work with specific design patterns that realize the broad, architectural paradigms of MVC and Model 2 architecture. Of the many available patterns, consider these three specific patterns, which can be used in combination: Service-to-Worker Dispatcher View Business Delegate

Service-to-Worker and Dispatcher View Patterns

2 1
Controller

4a

View JSP Components

Web-Tier Design Framework Construction


The Service-to-Worker and Dispatcher View patterns provide generic functionality that can be extracted to form a design framework. Each request is handled in the same generic way, with variations for the specific needs of the application. The controller element is the most generic, allowing reuse in different applications. The controllers functionality can be expressed declaratively, rather than in code.

Some Available Web-Tier Frameworks


Commonly used frameworks include: Struts JavaServer Faces technology

Business Delegate Pattern

BankMgrDelegate class

BankMgr

Controller

Web Tier

Business Logic Tier

You might also like