JEE Concepts
JEE Concepts
JEE Concepts
Single Tier:
Multi-Tiered Architecture
1. Programming Productivity
3. Freedom of Choice
4. Response to Demand
5. Maintaining Security
JEE (Java Enterprise Edition) Concepts
Definition:
Client
Dynamic HTML Page Client Tier
Application Client Machine
JSP
Web Tier
Pages
Database
EIS Tier Server
Database Database
Machine
Types of Containers:
1. Web Container
2. Application Client Container
3. EJB Container
J2EE Components:
Participate in transaction
Control access
Reusable
Guidelines for using Entity Beans
integrity of data.
Data collected and managed by entity bean is referred to as persistent data.
client.
data store, but they can access and update data on behalf of the
client.
Stateless means that the session bean does not maintain any state information
asynchronously.
The sender sends its message and does not need to wait for the receiver to
Storing data
1
6
E1
B
5
2
E2
3
4
C
D
Circuit Switching:
o Originally designed for voice traffic.
Processing Delay
Time
Call Accept Signal
User Data
Acknowledgement
Signal
Nodes 1 2 3 4
Packet Switching:
o Data set is broken up into a series of packets and are transmitted.
User Data
CI - Control Info.
o At each network node, packets are received, stored briefly and passed
onto the next node.
Packet Switching:
PKT1
PKT2
PKT3 PKT1
Time
PKT2
PKT3 PKT1
PKT2
PKT3
Nodes 1 2 3 4
Circuit and Packet Switching – A Comparison:
Possibility of Congestion
(overcrowding/jamming/blocking) At setup time On every packet
HTTP Request
Client Server
HTTP Response
Internet Listener
o Requests are sent to particular ports to reach the correct server process.
(Ex: HTTP requests - Port 80, SMTP request – Port 25).
o At the server, respective socket will be activated for the communication.
Sockets:
o Classification:
o Datagram Sockets – Connectionless
o Stream Sockets – Connection Oriented
o Raw Sockets (Raw IP Sockets) – Available in routers and
o HTTP is
o Connectionless
o Media (content type) Independent
o Stateless
Characteristics of HTTP Protocol:
o Bidirectional Transfer:
A browser requests a web page, and the server
transfers a copy to the browser.
Characteristics of HTTP Protocol:
o The format of the request and response messages are similar, and
English-oriented. Both kinds of messages consist of:
o An initial line
o Zero or more header lines
o A blank line and
o An optional message body.
Header1: value1
Header2: value2
Header3: value3
o An http method
o The local path of the requested resource
o The version of the http being used
o Response initial line called as status line also has three parts
HTTP/1.0 200 OK
or
HTTP/1.0 404 Not Found
Structure of HTTP Transactions HTTP Status Code
o The status code is a three-digit integer, and the first digit identifies the
general category of response:
HTTP/1.0 200 OK
or
o The header line provides information about the request and response.
o If the http message includes the body, then the header part describes the
body.
o Content-Type: type of data in the message body
http Methods:
o GET
o POST
o HEAD
Structure of HTTP Transactions
Client request
GET /index.html HTTP/1.1
Host: www.example.com
HTTP Headers
Server response
HTTP/1.1 200 OK
Date: Mon, 23 May 2005 22:38:34 GMT
Server: Apache/1.3.3.7 (Unix) (Red-Hat/Linux)
Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT
Etag: "3f80f-1b6-3e1cb03b"
Accept-Ranges: bytes
Content-Length: 438
Connection: close
Content-Type: text/html; charset=UTF-8
Structure of HTTP Transactions
Server response
HTTP/1.1 200 OK
Date: Mon, 23 May 2005 22:38:34 GMT
Server: Apache/1.3.3.7 (Unix) (Red-Hat/Linux)
Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT
Etag: "3f80f-1b6-3e1cb03b"
Accept-Ranges: bytes
Content-Length: 438
Connection: close
Content-Type: text/html; charset=UTF-8
<html>
<body>
<h1>Software Engineering</h1> (more file contents) . . .
</body>
</html>
Web Server Model:
Internet or
Internal Network
1. Enters URL 2. Sends request to web server
Web Web Server
Browser
4. Responds with HTML Page
5. Displays HTML
Internet or
Internal
Network
1. Enters URL 2. Sends request to web server
Web Web Server
Browser
5. Responds with HTML Page
6. Displays HTML
CGI Program /
Other Server side
scripts
2. The overhead of loading and running a program for each incoming request.
3. The need for tedious and repetitive coding to handle the network protocol
and request decoding.
4. Lack of portability
Creation:
Deployment:
HTML
First request since JSP is compiled
Java
application was into a Servlet
started HTML
Server
Server Servlet
All Subsequent requests Servlet
Web Browser
Compiled
J2EE Server / Standalone JSP Server
JSP Container (JSP Engine)
JSP Lifecycle:
JSP NO Translate
Java
Servlet JSP
Code
Exists? Source
YES File
Generate
Response
Directive Elements:
Are used to give special instruction to the JSP container about what to do
during the translation of the page.
Template Data:
Is the static text. This is passed directly through the JSP container
unprocessed.
Action Elements:
Are JSP elements that are involved in the processing of the request.
Scripting Elements:
Attribute Description
Ex: . . , usrpkg.*”
import = “java util *
Attribute Description
Attribute Description
Attribute Description
Attribute Description
Compilatio
Translation
n
<%@include...%> <%@include...%>
Incoming Outgoing
Request Response
Scripting Elements are the elements in the JSP that include Java code.
Scriptlet Code
Expression
Declaration
◊ The declarations appear only within the translated JSP page, but
not in the output to the client.
<%
sort(names);
%>
<%
out.print(" "+names[i]);
%>
<%!
void sort(String n[])
{
String nt = new String();
int i, j;
for( ; ; )
{
for( ; ; )
{
if (n[ ].compareTo(n[ ]) > 0)
{
Swap the contents of ith and jth
locations
}
}
}
}
%>
</body>
</html>
Scriptlet Code:
◊ Scriptlets are arbitrary Java code segments. Any legal java code
statement can appear within a scriptlet.
◊ The code in the scriptlet appears in the translated JSP, but not in
the output to the client.
◊ These comments will not appear in the page source received by the
client.
Template Data:
◊ All the HTML and text in the JSP page is Template data.
◊ All standard actions are prefixed by jsp: and have the following
general form.
◊ Some standard actions also have a body that can include other
tags. The body part of any standard action specify typically the
parameters that have to be used.
. . . More parameters
</jsp: tagname>
Action Elements:
Every property of the bean that is provided for the client use
has a method to set the value of the parameter, and a method
to get the value of the parameter. The methods have the
following form.
The JavaBean methods have the following form.
public type getSomeParameter()
{
return someParameter;
}
Attribute Description
The request object has request scope. That means that the
implicit request object is in scope until the response to the
client is complete.
The information sent to the server take two forms:
http://www.myserver.com/path/to/resource?name1=value1&name2=value2
The object can be used to set headers, set cookies for the client,
and send a redirect response to the client.
Using the session object, the page can store information about the
client or the client’s interaction.
JSP page can only store objects in the session, and not Java
primitives. To store Java primitives, wrapper classes such as
Integer, or Boolean etc., have to be used.
The methods for storing and retrieving session data are:
Object setAttribute(String name, Object value);
Object getAttribute(String name);
The session object has session scope, and all the objects stored in
the session object also have session scope.
The config Object:
application.getInitParameter(String name);