SlideShare ist ein Scribd-Unternehmen logo
1 von 49
Downloaden Sie, um offline zu lesen
© People Strategists www.peoplestrategists.com Slide 1 of 48
Overview of JEE Technologies
© People Strategists www.peoplestrategists.com Slide 2 of 48
Objectives
In this session, you will learn to:
Describe website and Web application
Identify Enterprise Application
Explore Servlet API
© People Strategists www.peoplestrategists.com Slide 3 of 48
A Web page is an electronic document, which is created using HTML
and is translated by the Web browser.
A Web pages can be :
Static
Dynamic
A website is a collection of one or more Web pages, which are hosted
on a Web server and are accessed by using client applications, such as a
Web browser.
A Website usually refers to the front-end interface through which the
users interacts with a business online.
A website consists of:
HTML and other graphic files
Audio and Video files
Other static files
Describing a Website and Web Application
© People Strategists www.peoplestrategists.com Slide 4 of 48
A Web application:
Is a program that is stored on a remote server and delivered over the
Internet through a Web browser using various protocols, such as HTTP.
Is a Website with dynamic functionality on the server and can be
controlled by the users.
To access a Web application:
A client sends a request to the Web server.
A Web server processes the request, generates the response, and sends
the response to the client.
Describing a Website and Web Application (Contd.)
© People Strategists www.peoplestrategists.com Slide 5 of 48
What is an enterprise
application?
Identifying an Enterprise Application
© People Strategists www.peoplestrategists.com Slide 6 of 48
An enterprise application is the term used to describe applications or
software that a business would use to assist the organization in solving
enterprise problems.
An enterprise application is an application that is:
Large in size
Distributed
Secure and scalable
Highly available
Accessible through multiple types of clients
Important aspects of an enterprise application are:
Presentation logic
Business logic
Data Access logic
System Services
Identifying an Enterprise Application (Contd.)
© People Strategists www.peoplestrategists.com Slide 7 of 48
Java Enterprise Edition:
Is Oracle's enterprise Java computing platform.
Is built upon the foundation of Java Platform, Standard Edition (Java SE).
Is an open and standard based platform for developing, deploying, and
managing n-tier, Web-enabled, server-centric, and
component-based enterprise applications.
It consists of a set of services, APIs, and protocols that provide the
functionality for developing multitier, Web-based applications.
Is a collection of related technology specifications that describe
required APIs and policies.
Identifying Java Enterprise Edition (EE)
© People Strategists www.peoplestrategists.com Slide 8 of 48
Identifying the Features of Java EE
Java EE comprises the following features:
Client tier support:
 J2EE supports pure HTML, as well as Java applets or applications.
 It relies on Java Server Pages and servlet code to create HTML or other formatted
data for the client.
Middle Layer support:
 J2EE supports Enterprise JavaBeans (EJBs) as middle layer, where the platform's
logic is stored.
Java Database Connectivity (JDBC):
 J2EE supports JDBC, which is the Java equivalent to ODBC.
JavaMail API:
 It consists of libraries to create, send, receive, and read email messages.
 It enables the J2EE applications to handle mail messages easily.
 It supports the IMAP4, POP3, and SMTP mail protocols.
© People Strategists www.peoplestrategists.com Slide 9 of 48
Identifying the Features of Java EE (Contd.)
Java Naming and Directory Interface (JNDI) API:
 It enables application components and clients to search and link distributed
resources, services, and EJB components.
 It allows the configuration of external and custom resources in the Sun ONE
Application Server.
Java Message Service (JMS) API:
 It enables the J2EE applications to create, send, receive, and read messages in a
distributed environment.
 It uses JMS queues, topics, and message destinations, which are made available
using the JNDI API.
© People Strategists www.peoplestrategists.com Slide 10 of 48
Identifying Various Types of Java EE Container
Various types of Java EE containers are:
Web container: Provides a runtime environment to manage deployed Web
components, such as servlets and JSP.
Applet container: Provides the runtime environment for executing applets.
EJB container: Provides a runtime environment to manage deployed EJB
components.
Application client container: Provides a runtime environment for Java EE
application clients.
The following figure depicts the interaction between different Java EE
containers.
Application
client container
Applet container
Web container
EJB container
Database
© People Strategists www.peoplestrategists.com Slide 11 of 48
Identifying JAR, WAR, and EAR
In J2EE application, modules are packaged as Java archive (JAR), Web
archive (WAR), and Enterprise archive (EAR) based on their functionality.
JAR:
Is a package file format that is used to group Java class files and associated
metadata and resources into one file.
Is used to distribute application software or libraries on the Java platform.
WAR:
Is used to package a Web application, which is a group of JSP, HTML, servlets,
resources and source files.
Includes a Web deployment descriptor file and can be used to import a Web
application into a Web server.
EAR:
Is used by Java EE for packaging one or more modules into a single archive.
Is used to enable the deployment of the various modules onto an
application simultaneously and coherently.
© People Strategists www.peoplestrategists.com Slide 12 of 48
Identifying Various Java EE APIs and Technologies
Java EE comprises of the following APIs and technologies:
Standard Edition (Java SE)
Java Servlets
Java Server Pages™ (JSP™)
Java Server Faces™ (JSF™)
Remote Method Invocation (RMI)
Java Persistence API (JPA)
Java Message Service (JMS) API
Java Naming and Directory Interface™ (JNDI) API
Java Transaction API (JTA)
Enterprise JavaBeans™ (EJB™) components
Java API for XML Web Services (JAX-WS)
© People Strategists www.peoplestrategists.com Slide 13 of 48
Identifying Java Servlet
A Servlet is a Java program that runs on a server and used to
generate dynamic Web pages.
Servlets performs the following tasks:
Processes HTTP requests
Generates dynamic HTTP responses
Servlets act as a middle layer between a request coming from a
Web browser or other HTTP client and databases.
Servlets executes inside a Web container as a thread.
The following figure depicts the position of the servlet in a Web
application.
HTTP Server
Web Browser
Servlet Program
Database
HTTP
Protocol
© People Strategists www.peoplestrategists.com Slide 14 of 48
Identifying the Advantages of Java Servlet
Some of the advantages of Java servlets are:
Servlets are faster than CGI programs because each scripts in CGI
produces a new process and these processes takes a lot of time for
execution. However, servlets creates only new thread.
Servlets are server side components that inherits the security
provided by the Web server and Java Security Manager.
Servlets provide all the powerful features of Java, such as exception
handling and garbage collection.
Servlets are portable across operating systems and across Web
servers as servlets are write once, run anywhere (WORA) programs
written in Java.
Servlets can share data among each other and can maintain the
session which helps them to maintain information from request to
request.
The servlet API is designed in such a way that it can be easily
extensible.
© People Strategists www.peoplestrategists.com Slide 15 of 48
Identifying the Limitation of Java Servlet
Some of the limitations of Java servlets are:
Whenever a Web page changes, the servlet needs to be rewritten,
recompiled, and redeployed.
Servlets must handle concurrency issues.
Tedious uses of out.println()statements.
Designing in servlet is difficult and slows down the application.
Writing complex business logic makes the application difficult to
understand.
© People Strategists www.peoplestrategists.com Slide 16 of 48
Identify Servlet Terminology
Basic terminologies used in servlet are:
Hypertext Transfer Protocol (HTTP)
HTTP request
HTTP response
Difference between Web server and application server
Web container
© People Strategists www.peoplestrategists.com Slide 17 of 48
Identifying HTTP Protocol
HTTP is a protocol that is used by a client and a server to communicate
with each other.
It supports only one request per connection.
It can be used to transmit any file that follows the Multipurpose
Internet Mail Extensions (MIME) specification.
It uses the request and response process to transfer information from
one computer to another
© People Strategists www.peoplestrategists.com Slide 18 of 48
Identifying HTTP Request
HTTP request is like an envelope, which contains the necessary
information required by the Web server to process a client request.
An HTTP request consists of:
Request line: It contains request method, request URL, and version.
Request header: It contains additional information about the client, such as
the name and the version of the Web browser.
Message body: It is an optional part of the HTTP request. It contains the data
entered by a user that needs processed.
The following figure describes an HTTP request.
© People Strategists www.peoplestrategists.com Slide 19 of 48
Identifying HTTP Response
HTTP response is like an envelope that contains the response generated
by a server that would be displayed by a Web browser.
The HTTP response consists of:
Status line: It consists of status code, reason phrase, and version of the
HTTP protocol.
Response header: It contains additional information about the Web server.
Message body: It consists of the response in the form of Hyper Text Markup
Language (HTML) format.
The following figure describes an HTTP response.
© People Strategists www.peoplestrategists.com Slide 20 of 48
Difference Between the Web Server and Application Server
Web Server Application Server
Web server handles the HTTP
protocol.
Whenever, a Web server receives
an HTTP request, it responds with
an HTTP response.
It may respond with a static HTML
page or image, send or redirect,
or delegate the dynamic response
generation to some other
program such as CGI scripts, JSPs
(Java Server Pages), Servlets.
An application server exposes
business logic to client
applications through various
protocols like HTTP, TCP-IP etc.
An application server providers
allows the client to access the
business logic for use.
An application server is used to
run business logic or dynamically
generating presentation code.
An application server is more
capable of dynamic behavior
than web server.
The following points depicts the differences between the Web server and
Application server:
© People Strategists www.peoplestrategists.com Slide 21 of 48
Identifying Web Container
What is a Web container?
© People Strategists www.peoplestrategists.com Slide 22 of 48
Identifying Web Container (Contd.)
Web container is a Java virtual machine
that supplies an implementation of the
Java Servlet API.
All Java servlets must exist in the Web
container.
Web Container activate the servlet that
match to request.
© People Strategists www.peoplestrategists.com Slide 23 of 48
The following figure depicts how the Web container handles the client
request.
Web server
Client
Web
container
Servlet
Thread
Service()
doGet()
<html>
<body>
-----------
</body>
</html>
Identifying Web Container (Contd.)
© People Strategists www.peoplestrategists.com Slide 24 of 48
Execution Process of Java Servlets
Following steps illustrates how a Java servlet executes:
1. The client sends request to the server.
2. The Web container, running inside the server, receives the request.
3. The Web container creates a new thread to process the request.
4. The Web container forwards the request to the servlet.
5. The Web container executes the servlet.
© People Strategists www.peoplestrategists.com Slide 25 of 48
Execution Process of Java Servlets (Contd.)
The following figure depicts the execution process of a servlet
with a single request.
© People Strategists www.peoplestrategists.com Slide 26 of 48
Execution Process of Java Servlets (Contd.)
The following figure depicts the execution process of a servlet
with multiple requests.
Processor’s load does not increase much on execution of multiple
requests.
© People Strategists www.peoplestrategists.com Slide 27 of 48
Exploring Servlet API (Contd.)
Servlet API:
is used to create and manage servlets.
consists of various interfaces, classes, and methods.
classes and methods are available in the following packages:
 javax.servlet
 javax.servlet.http
© People Strategists www.peoplestrategists.com Slide 28 of 48
Exploring Servlet API (Contd.)
The following figure depicts the class hierarchy of the Servlet API.
Servlet API
ServletException
Javax.servlet.http
Servlet
ServletConfig
ServletContext
ServletRequest
ServletResponse
AsyncContext
Javax.servlet
GenericServlet
Cookie
HttpServletRequest
HttpServletResponse
HttpSession
HttpServlet
Packages
Classes
Interfaces
RequestDispatcher
© People Strategists www.peoplestrategists.com Slide 29 of 48
The javax.servlet package:
consists of the following interfaces, as described in the table.
Interface Description
Servlet It provides the methods that all servlets must implement.
ServletConfig It provides information to the servlets during the servlet
initialization.
ServletContext It provides methods, which is used by the servlets to
communicate with the Web container.
ServletRequest It provides the client request information to the servlet.
ServletResponse It helps the servlet in sending the response to the client.
RequestDispatcher It receives a request from a client and sends it to any other
resource, such as a servlet, an HTML page, or a JSP page.
AsyncContext It provides the methods to handle multiple client requests
asynchronously.
Exploring Servlet API (Contd.)
© People Strategists www.peoplestrategists.com Slide 30 of 48
The Servlet interface methods are implemented by the servlet class
that extends from a GenericServlet or HttpServlet class.
The following table describes the various methods defined in the
Servlet interface:
Exploring Servlet API (Contd.)
Method Description
void init(ServletConfig config)
throws ServletException
It is called by the servlet container to indicate
to a servlet that the servlet is being placed
into service.
ServletConfig getServletConfig() Returns a ServletConfig object, which
contains initialization and startup parameters
for this servlet.
String getServletInfo() Returns information about the servlet, such as
author, version, and copyright.
void service(ServletRequest request,
ServletResponse response) throws
ServletException, IOException
It is Called by the servlet container to allow
the servlet to respond to a request.
void destroy() Called by the servlet container to indicate to a
servlet that the servlet is being taken out of
service.
© People Strategists www.peoplestrategists.com Slide 31 of 48
The following table describes the various methods defined in the
ServletRequest interface:
Exploring Servlet API (Contd.)
Method Description
public String getParameter(String
paramName)
Returns a String object that specifies the
value of a particular request parameter.
public String[]
getParameterValues(String paramName)
Returns an array of String objects that
contains all the values of the request
parameter.
public Enumeration
getParameterNames()
Returns an Enumeration object containing
all the parameter names as String objects
that `request contains.
public String getRemoteHost() Returns a String object that specifies the
full-qualified name of the computer from
which the request is sent.
public String getRemoteAddr() Returns a String object that specifies the IP
address of the computer from which the
request is sent.
© People Strategists www.peoplestrategists.com Slide 32 of 48
The following table describes the various methods defined in the
ServletResponse interface:
Exploring Servlet API (Contd.)
Method Description
public ServletOutputStream
getOutputStream() throws
IOException
Returns an object of the
ServletOutputStream class that
represents an output stream to send
binary data as response.
public PrintWriter getWriter()
throws IOException
Returns an object of the PrintWriter
class that the servlet uses to send
character data as response.
public void setContentType(String
type)
Sets the MIME type for a servlet response.
Some of the MIME types are text/plain,
image/jpeg, and text/html.
© People Strategists www.peoplestrategists.com Slide 33 of 48
The javax.servlet package:
Consists of the following classes:
 GenericServlet
 ServletException
The GenericServlet class defines a generic, protocol-independent
servlet.
The GenericServlet implements the Servlet and ServletConfig
interfaces .
The ServletException class defines a general exception a servlet can
throw when it encounters difficulty.
The ServletException class contains the following constructors:
 ServletException()
 ServletException(String message)
 ServletException(String message, Throwable rootCause)
Exploring Servlet API (Contd.)
© People Strategists www.peoplestrategists.com Slide 34 of 48
The following code illustrates a simple example of servlet by inheriting
the GenericServlet class:
Exploring Servlet API (Contd.)
import java.io.*;
import javax.servlet.*;
public class myFirstServlet extends GenericServlet{
public void service(ServletRequest req,
ServletResponse res)throws IOException,
ServletException {
res.setContentType("text/html");
PrintWriter out=res.getWriter();
out.print("<html><body>");
out.print("<b>hello generic servlet</b>");
out.print("</body></html>");
}
}
© People Strategists www.peoplestrategists.com Slide 35 of 48
Exploring Servlet API (Contd.)
The javax.servlet.http package:
Provides classes and interfaces that enable you to create a servlet that
communicates using the HTTP protocol.
Provides the HttpServlet class to create servlets, which is an abstract class.
Provides the HttpServlet class that extends the GenericServlet class
and implements Serializable interface.
Provides HTTP specific methods, such as doGet, doPost, and doHead.
Some of the interfaces of the javax.servlet.http package are:`
HttpServletRequest
HttpServletResponse
HttpSession
© People Strategists www.peoplestrategists.com Slide 36 of 48
The following table describes the various methods defined in the
HttpServletRequest interface:
Exploring Servlet API (Contd.)
Method Description
public String getHeader(String
fieldname)
Returns the value of the request header
field, such as Cache-Control and
Accept-Language, specified in the
parameter.
public Enumeration
getHeaders(String sname)
Returns all the values associated with a
specific request header as an enumeration
of String objects.
public Enumeration
getHeaderNames()
Returns the names of all the request
headers that a servlet can access as an
enumeration of String objects.
© People Strategists www.peoplestrategists.com Slide 37 of 48
The following table describes the various methods defined in the
HttpServletResponse interface:
Exploring Servlet API (Contd.)
Method Description
void setHeader(String hname, String
hvalue)
Sets the value of header hname to hvalue. If
the header has already been set, the new
value overwrites the existing value.
void setIntHeader(String hname, int
hvalue)
Sets the value of the header hname to the int
value, hvalue. If the header has already been
set, the new value overwrites the existing
value.
void addHeader(String hname, String
hvalue)
Adds a header hname with value hvalue. This
method adds a new header if the header
already exists.
void addIntHeader(String hname, int
hvalue)
Adds a header hname with an int value,
hvalue.
boolean containsHeader(String hname) Returns true if the header hname has already
been set with a specific value and false, if not.
void sendRedirect(String url) Redirects a request to the specified URL.
© People Strategists www.peoplestrategists.com Slide 38 of 48
The following table describes the various methods defined in the
HttpSession interface:
Exploring Servlet API (Contd.)
Method Description
public void setAttribute(String name,
Object value)
Binds the object with a name and stores the
name/value pair as an attribute of the
HttpSession object. If an attribute already
exists, this method replaces the existing
attribute.
public Object getAttribute(String
name)
Retrieves the String object specified in the
parameter, from the session object. If no
object is found for the specified attribute, the
getAttribute()method returns null.
public Enumeration
getAttributeNames()
Returns an Enumeration object that contains
the name of all the objects that are bound as
attributes to the session object.
© People Strategists www.peoplestrategists.com Slide 39 of 48
The following code illustrates a simple example of servlet by inheriting
the HttpServlet class:
Exploring Servlet API (Contd.)
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class myFirstHttpServlet extends HttpServlet
{
public void doGe(HttpServletRequest request,
HttpServletResponse response)throws IOException{
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<body>");
out.println("<h1>Hello Servlet Get</h1>");
out.println("</body>");
out.println("</html>");
}
}
© People Strategists www.peoplestrategists.com Slide 40 of 48
Identifying Servlet Life Cycle
Process the request- service()
Loading servlet, Instantiate and
Initialization - init()
Unload servlets / Take out of
service - destroy()
doGet() or doPost()
Calls
Calls
Calls
The Web container maintains the life cycle of a servlet instance.
The following figure depicts the life cycle of Java servlet.
1. Servlet class is loaded.
2. Servlet instance is created.
3. init()method is invoked.
4. service()method is invoked.
5. destroy()method is invoked.
© People Strategists www.peoplestrategists.com Slide 41 of 48
Implementing a Servlet
To create a servlet, you need to perform the following tasks:
Create a servlet.
Configure the servlet.
Compile and deploy the servlet.
Access the servlet using a browser application.
© People Strategists www.peoplestrategists.com Slide 42 of 48
Creating a Servlet
Servlet can be created by extending the HttpServlet or
GenericServlet class.
Example:
Consider a scenario in which you have to create servlet that displays
the current date to the user, each time the servlet is accessed. To do
this, you have to create a servlet that extends from the HttpServlet
class, as shown in the embedded file.
© People Strategists www.peoplestrategists.com Slide 43 of 48
Configuring a Servlet
Configuring a servlet means, associating a URL with the servlet.
Servlets can be configured using either of the way:
Deployment descriptor (DD)
Annotations
A deployment descriptor is an XML file with the name web.xml that
contains configuration information of a Web application.
Each Web application contains one web.xml file.
The elements of the web.xml file enable you to specify:
Servlet context initialization parameters of a Web application.
Initialization parameter for the servlet.
Mapping between a file extension and a MIME type.
Mapping between a servlet and a URL pattern.
The name of the listener class that responds to a servlet life cycle event.
© People Strategists www.peoplestrategists.com Slide 44 of 48
Configuring a Servlet (Contd.)
Some of the commonly used elements of the web.xml file along with
their usage are:
<servlet>: specifies the configuration details of all the servlets used in a
Web application and contains the following sub elements:
 <servlet-name>
 <servlet-class>
<servlet-mapping>: consists of following sub elements:
 <servlet-name>
 <url-pattern>
<session-config>
<init-param>
<mime-mapping>
Sample DD file:
© People Strategists www.peoplestrategists.com Slide 45 of 48
Configuring a Servlet (Contd.)
Configuring a servlet by using annotations:
The javax.servlet.annotation package defines the @WebServer
annotation that you can use to configure a servlet, as shown in the
following sample code snippet:
@WebServer(name="MyFirstServlet",
urlPatterns={"/MyFirstServlet", "/MyServlet/*"})
public class MyFirstServlet extends HttpServlet
{
…
}
The @WebServer annotation is used to configure the MyFirstServlet
servlet. The name attribute specifies the name of the servlet. The
urlPatterns attribute is used to map the servlet with the URL patterns.
© People Strategists www.peoplestrategists.com Slide 46 of 48
Compile and Deploy the Servlet on Server
To You can compile and deploy your application using your
Eclipse IDE.
Finally, you can access the Web application using the URL, as
shown the following code snippet:
Http://Localhost:8080/myApplication/
© People Strategists www.peoplestrategists.com Slide 47 of 48
Summary
A Web page is an electronic document, which is created using HTML
and is translated by the Web browser.
A website is a collection of one or more Web pages, which are
hosted on a Web server and are accessed by using client
applications, such as a Web browser.
A Web application is a program that is stored on a remote server
and delivered over the Internet through a Web browser using
various protocols, such as HTTP.
An enterprise application is the term used to describe applications
or software that a business would use to assist the organization in
solving enterprise problems.
Java EE is built upon the foundation of Java Platform, Standard
Edition (Java SE).
Web container provides a runtime environment to manage deployed
Web components, such as servlets and JSP.
© People Strategists www.peoplestrategists.com Slide 48 of 48
Summary (Contd.)
Applet container provides the runtime environment for executing
applets.
EJB container provides a runtime environment to manage deployed
EJB components.
Application client container provides a runtime environment for Java
EE application clients.
Java Servlet API consists of two packages:
javax.servlet package
javax.servlet.http package
The various interfaces of javax.servlet package are:
ServletRequest interface
ServletContext interface
ServletResponse interface
© People Strategists www.peoplestrategists.com Slide 49 of 48
Summary (Contd.)
Servlet interface provides the methods that all servlets must
implement.
The GenericServlet class defines a generic, protocol-independent
servlet.
The GenericServlet implements the Servlet and ServletConfig
interfaces .
The ServletException class defines a general exception a servlet can
throw when it encounters difficulty.
The HttpServlet class is used to create a servlets that communicates
using the HTTP protocol.
The HttpServlet class that extends the GenericServlet class and
implements Serializable interface.

Weitere ähnliche Inhalte

Was ist angesagt?

Hibernate tutorial for beginners
Hibernate tutorial for beginnersHibernate tutorial for beginners
Hibernate tutorial for beginnersRahul Jain
 
Hibernate presentation
Hibernate presentationHibernate presentation
Hibernate presentationManav Prasad
 
Java Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and ExampleJava Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and Examplekamal kotecha
 
TY.BSc.IT Java QB U5&6
TY.BSc.IT Java QB U5&6TY.BSc.IT Java QB U5&6
TY.BSc.IT Java QB U5&6Lokesh Singrol
 
Hibernate Interview Questions
Hibernate Interview QuestionsHibernate Interview Questions
Hibernate Interview QuestionsSyed Shahul
 
jpa-hibernate-presentation
jpa-hibernate-presentationjpa-hibernate-presentation
jpa-hibernate-presentationJohn Slick
 
Server side programming bt0083
Server side programming bt0083Server side programming bt0083
Server side programming bt0083Divyam Pateriya
 
Learn about dot net attributes
Learn about dot net attributesLearn about dot net attributes
Learn about dot net attributessonia merchant
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate pptAneega
 
Hibernate
HibernateHibernate
HibernateAjay K
 
24 collections framework interview questions
24 collections framework interview questions24 collections framework interview questions
24 collections framework interview questionsArun Vasanth
 

Was ist angesagt? (18)

Spring Framework -I
Spring Framework -ISpring Framework -I
Spring Framework -I
 
Hibernate tutorial for beginners
Hibernate tutorial for beginnersHibernate tutorial for beginners
Hibernate tutorial for beginners
 
Hibernate in Action
Hibernate in ActionHibernate in Action
Hibernate in Action
 
TY.BSc.IT Java QB U4
TY.BSc.IT Java QB U4TY.BSc.IT Java QB U4
TY.BSc.IT Java QB U4
 
TY.BSc.IT Java QB U5
TY.BSc.IT Java QB U5TY.BSc.IT Java QB U5
TY.BSc.IT Java QB U5
 
Hibernate presentation
Hibernate presentationHibernate presentation
Hibernate presentation
 
Java Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and ExampleJava Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and Example
 
TY.BSc.IT Java QB U3
TY.BSc.IT Java QB U3TY.BSc.IT Java QB U3
TY.BSc.IT Java QB U3
 
TY.BSc.IT Java QB U5&6
TY.BSc.IT Java QB U5&6TY.BSc.IT Java QB U5&6
TY.BSc.IT Java QB U5&6
 
Jdbc
JdbcJdbc
Jdbc
 
Hibernate Interview Questions
Hibernate Interview QuestionsHibernate Interview Questions
Hibernate Interview Questions
 
jpa-hibernate-presentation
jpa-hibernate-presentationjpa-hibernate-presentation
jpa-hibernate-presentation
 
Server side programming bt0083
Server side programming bt0083Server side programming bt0083
Server side programming bt0083
 
Hibernate tutorial
Hibernate tutorialHibernate tutorial
Hibernate tutorial
 
Learn about dot net attributes
Learn about dot net attributesLearn about dot net attributes
Learn about dot net attributes
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate ppt
 
Hibernate
HibernateHibernate
Hibernate
 
24 collections framework interview questions
24 collections framework interview questions24 collections framework interview questions
24 collections framework interview questions
 

Ähnlich wie Overview of JEE Technology

Intorduction to struts
Intorduction to strutsIntorduction to struts
Intorduction to strutsAnup72
 
Project report for final year project
Project report for final year projectProject report for final year project
Project report for final year projectsuneel singh
 
Web programming and development - Introduction
Web programming and development - IntroductionWeb programming and development - Introduction
Web programming and development - IntroductionJoel Briza
 
Introduction Java Web Framework and Web Server.
Introduction Java Web Framework and Web Server.Introduction Java Web Framework and Web Server.
Introduction Java Web Framework and Web Server.suranisaunak
 
J2EE Notes JDBC database Connectiviy and Programs related to JDBC
J2EE Notes JDBC database Connectiviy and Programs related to JDBCJ2EE Notes JDBC database Connectiviy and Programs related to JDBC
J2EE Notes JDBC database Connectiviy and Programs related to JDBCChaithraCSHirematt
 
J2 EEE SIDES
J2 EEE  SIDESJ2 EEE  SIDES
J2 EEE SIDESbputhal
 
Online test management system
Online test management systemOnline test management system
Online test management systemPrateek Agarwak
 
Introduction to ejb and struts framework
Introduction to ejb and struts frameworkIntroduction to ejb and struts framework
Introduction to ejb and struts frameworks4al_com
 
Framework adoption for java enterprise application development
Framework adoption for java enterprise application developmentFramework adoption for java enterprise application development
Framework adoption for java enterprise application developmentClarence Ho
 

Ähnlich wie Overview of JEE Technology (20)

Intorduction to struts
Intorduction to strutsIntorduction to struts
Intorduction to struts
 
Enterprice java
Enterprice javaEnterprice java
Enterprice java
 
Project report for final year project
Project report for final year projectProject report for final year project
Project report for final year project
 
Java EE 7 introduction
Java EE 7  introductionJava EE 7  introduction
Java EE 7 introduction
 
Java ee introduction
Java ee introductionJava ee introduction
Java ee introduction
 
Java J2EE
Java J2EEJava J2EE
Java J2EE
 
Java part 3
Java part  3Java part  3
Java part 3
 
Web programming and development - Introduction
Web programming and development - IntroductionWeb programming and development - Introduction
Web programming and development - Introduction
 
Introduction Java Web Framework and Web Server.
Introduction Java Web Framework and Web Server.Introduction Java Web Framework and Web Server.
Introduction Java Web Framework and Web Server.
 
Servlet by Rj
Servlet by RjServlet by Rj
Servlet by Rj
 
J2EE Notes JDBC database Connectiviy and Programs related to JDBC
J2EE Notes JDBC database Connectiviy and Programs related to JDBCJ2EE Notes JDBC database Connectiviy and Programs related to JDBC
J2EE Notes JDBC database Connectiviy and Programs related to JDBC
 
J2 EEE SIDES
J2 EEE  SIDESJ2 EEE  SIDES
J2 EEE SIDES
 
Online test management system
Online test management systemOnline test management system
Online test management system
 
Introduction to ejb and struts framework
Introduction to ejb and struts frameworkIntroduction to ejb and struts framework
Introduction to ejb and struts framework
 
Assignment3.2
Assignment3.2Assignment3.2
Assignment3.2
 
4. J2EE.pptx
4. J2EE.pptx4. J2EE.pptx
4. J2EE.pptx
 
soa1.ppt
soa1.pptsoa1.ppt
soa1.ppt
 
Java Interview Questions
Java Interview QuestionsJava Interview Questions
Java Interview Questions
 
Framework adoption for java enterprise application development
Framework adoption for java enterprise application developmentFramework adoption for java enterprise application development
Framework adoption for java enterprise application development
 
Naga Srinivas
Naga SrinivasNaga Srinivas
Naga Srinivas
 

Mehr von People Strategists (20)

MongoDB Session 3
MongoDB Session 3MongoDB Session 3
MongoDB Session 3
 
MongoDB Session 2
MongoDB Session 2MongoDB Session 2
MongoDB Session 2
 
MongoDB Session 1
MongoDB Session 1MongoDB Session 1
MongoDB Session 1
 
Android - Day 1
Android - Day 1Android - Day 1
Android - Day 1
 
Android - Day 2
Android - Day 2Android - Day 2
Android - Day 2
 
Overview of web services
Overview of web servicesOverview of web services
Overview of web services
 
Identifing Listeners and Filters
Identifing Listeners and FiltersIdentifing Listeners and Filters
Identifing Listeners and Filters
 
Exploring Maven SVN GIT
Exploring Maven SVN GITExploring Maven SVN GIT
Exploring Maven SVN GIT
 
Agile Dev. II
Agile Dev. IIAgile Dev. II
Agile Dev. II
 
Agile Dev. I
Agile Dev. IAgile Dev. I
Agile Dev. I
 
XML Schemas
XML SchemasXML Schemas
XML Schemas
 
JSON and XML
JSON and XMLJSON and XML
JSON and XML
 
Ajax and Jquery
Ajax and JqueryAjax and Jquery
Ajax and Jquery
 
CSS
CSSCSS
CSS
 
HTML/HTML5
HTML/HTML5HTML/HTML5
HTML/HTML5
 
JDBC
JDBCJDBC
JDBC
 
RDBMS with MySQL
RDBMS with MySQLRDBMS with MySQL
RDBMS with MySQL
 
Java Day-7
Java Day-7Java Day-7
Java Day-7
 
Java Day-6
Java Day-6Java Day-6
Java Day-6
 
Final Table of Content
Final Table of ContentFinal Table of Content
Final Table of Content
 

Kürzlich hochgeladen

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 

Kürzlich hochgeladen (20)

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

Overview of JEE Technology

  • 1. © People Strategists www.peoplestrategists.com Slide 1 of 48 Overview of JEE Technologies
  • 2. © People Strategists www.peoplestrategists.com Slide 2 of 48 Objectives In this session, you will learn to: Describe website and Web application Identify Enterprise Application Explore Servlet API
  • 3. © People Strategists www.peoplestrategists.com Slide 3 of 48 A Web page is an electronic document, which is created using HTML and is translated by the Web browser. A Web pages can be : Static Dynamic A website is a collection of one or more Web pages, which are hosted on a Web server and are accessed by using client applications, such as a Web browser. A Website usually refers to the front-end interface through which the users interacts with a business online. A website consists of: HTML and other graphic files Audio and Video files Other static files Describing a Website and Web Application
  • 4. © People Strategists www.peoplestrategists.com Slide 4 of 48 A Web application: Is a program that is stored on a remote server and delivered over the Internet through a Web browser using various protocols, such as HTTP. Is a Website with dynamic functionality on the server and can be controlled by the users. To access a Web application: A client sends a request to the Web server. A Web server processes the request, generates the response, and sends the response to the client. Describing a Website and Web Application (Contd.)
  • 5. © People Strategists www.peoplestrategists.com Slide 5 of 48 What is an enterprise application? Identifying an Enterprise Application
  • 6. © People Strategists www.peoplestrategists.com Slide 6 of 48 An enterprise application is the term used to describe applications or software that a business would use to assist the organization in solving enterprise problems. An enterprise application is an application that is: Large in size Distributed Secure and scalable Highly available Accessible through multiple types of clients Important aspects of an enterprise application are: Presentation logic Business logic Data Access logic System Services Identifying an Enterprise Application (Contd.)
  • 7. © People Strategists www.peoplestrategists.com Slide 7 of 48 Java Enterprise Edition: Is Oracle's enterprise Java computing platform. Is built upon the foundation of Java Platform, Standard Edition (Java SE). Is an open and standard based platform for developing, deploying, and managing n-tier, Web-enabled, server-centric, and component-based enterprise applications. It consists of a set of services, APIs, and protocols that provide the functionality for developing multitier, Web-based applications. Is a collection of related technology specifications that describe required APIs and policies. Identifying Java Enterprise Edition (EE)
  • 8. © People Strategists www.peoplestrategists.com Slide 8 of 48 Identifying the Features of Java EE Java EE comprises the following features: Client tier support:  J2EE supports pure HTML, as well as Java applets or applications.  It relies on Java Server Pages and servlet code to create HTML or other formatted data for the client. Middle Layer support:  J2EE supports Enterprise JavaBeans (EJBs) as middle layer, where the platform's logic is stored. Java Database Connectivity (JDBC):  J2EE supports JDBC, which is the Java equivalent to ODBC. JavaMail API:  It consists of libraries to create, send, receive, and read email messages.  It enables the J2EE applications to handle mail messages easily.  It supports the IMAP4, POP3, and SMTP mail protocols.
  • 9. © People Strategists www.peoplestrategists.com Slide 9 of 48 Identifying the Features of Java EE (Contd.) Java Naming and Directory Interface (JNDI) API:  It enables application components and clients to search and link distributed resources, services, and EJB components.  It allows the configuration of external and custom resources in the Sun ONE Application Server. Java Message Service (JMS) API:  It enables the J2EE applications to create, send, receive, and read messages in a distributed environment.  It uses JMS queues, topics, and message destinations, which are made available using the JNDI API.
  • 10. © People Strategists www.peoplestrategists.com Slide 10 of 48 Identifying Various Types of Java EE Container Various types of Java EE containers are: Web container: Provides a runtime environment to manage deployed Web components, such as servlets and JSP. Applet container: Provides the runtime environment for executing applets. EJB container: Provides a runtime environment to manage deployed EJB components. Application client container: Provides a runtime environment for Java EE application clients. The following figure depicts the interaction between different Java EE containers. Application client container Applet container Web container EJB container Database
  • 11. © People Strategists www.peoplestrategists.com Slide 11 of 48 Identifying JAR, WAR, and EAR In J2EE application, modules are packaged as Java archive (JAR), Web archive (WAR), and Enterprise archive (EAR) based on their functionality. JAR: Is a package file format that is used to group Java class files and associated metadata and resources into one file. Is used to distribute application software or libraries on the Java platform. WAR: Is used to package a Web application, which is a group of JSP, HTML, servlets, resources and source files. Includes a Web deployment descriptor file and can be used to import a Web application into a Web server. EAR: Is used by Java EE for packaging one or more modules into a single archive. Is used to enable the deployment of the various modules onto an application simultaneously and coherently.
  • 12. © People Strategists www.peoplestrategists.com Slide 12 of 48 Identifying Various Java EE APIs and Technologies Java EE comprises of the following APIs and technologies: Standard Edition (Java SE) Java Servlets Java Server Pages™ (JSP™) Java Server Faces™ (JSF™) Remote Method Invocation (RMI) Java Persistence API (JPA) Java Message Service (JMS) API Java Naming and Directory Interface™ (JNDI) API Java Transaction API (JTA) Enterprise JavaBeans™ (EJB™) components Java API for XML Web Services (JAX-WS)
  • 13. © People Strategists www.peoplestrategists.com Slide 13 of 48 Identifying Java Servlet A Servlet is a Java program that runs on a server and used to generate dynamic Web pages. Servlets performs the following tasks: Processes HTTP requests Generates dynamic HTTP responses Servlets act as a middle layer between a request coming from a Web browser or other HTTP client and databases. Servlets executes inside a Web container as a thread. The following figure depicts the position of the servlet in a Web application. HTTP Server Web Browser Servlet Program Database HTTP Protocol
  • 14. © People Strategists www.peoplestrategists.com Slide 14 of 48 Identifying the Advantages of Java Servlet Some of the advantages of Java servlets are: Servlets are faster than CGI programs because each scripts in CGI produces a new process and these processes takes a lot of time for execution. However, servlets creates only new thread. Servlets are server side components that inherits the security provided by the Web server and Java Security Manager. Servlets provide all the powerful features of Java, such as exception handling and garbage collection. Servlets are portable across operating systems and across Web servers as servlets are write once, run anywhere (WORA) programs written in Java. Servlets can share data among each other and can maintain the session which helps them to maintain information from request to request. The servlet API is designed in such a way that it can be easily extensible.
  • 15. © People Strategists www.peoplestrategists.com Slide 15 of 48 Identifying the Limitation of Java Servlet Some of the limitations of Java servlets are: Whenever a Web page changes, the servlet needs to be rewritten, recompiled, and redeployed. Servlets must handle concurrency issues. Tedious uses of out.println()statements. Designing in servlet is difficult and slows down the application. Writing complex business logic makes the application difficult to understand.
  • 16. © People Strategists www.peoplestrategists.com Slide 16 of 48 Identify Servlet Terminology Basic terminologies used in servlet are: Hypertext Transfer Protocol (HTTP) HTTP request HTTP response Difference between Web server and application server Web container
  • 17. © People Strategists www.peoplestrategists.com Slide 17 of 48 Identifying HTTP Protocol HTTP is a protocol that is used by a client and a server to communicate with each other. It supports only one request per connection. It can be used to transmit any file that follows the Multipurpose Internet Mail Extensions (MIME) specification. It uses the request and response process to transfer information from one computer to another
  • 18. © People Strategists www.peoplestrategists.com Slide 18 of 48 Identifying HTTP Request HTTP request is like an envelope, which contains the necessary information required by the Web server to process a client request. An HTTP request consists of: Request line: It contains request method, request URL, and version. Request header: It contains additional information about the client, such as the name and the version of the Web browser. Message body: It is an optional part of the HTTP request. It contains the data entered by a user that needs processed. The following figure describes an HTTP request.
  • 19. © People Strategists www.peoplestrategists.com Slide 19 of 48 Identifying HTTP Response HTTP response is like an envelope that contains the response generated by a server that would be displayed by a Web browser. The HTTP response consists of: Status line: It consists of status code, reason phrase, and version of the HTTP protocol. Response header: It contains additional information about the Web server. Message body: It consists of the response in the form of Hyper Text Markup Language (HTML) format. The following figure describes an HTTP response.
  • 20. © People Strategists www.peoplestrategists.com Slide 20 of 48 Difference Between the Web Server and Application Server Web Server Application Server Web server handles the HTTP protocol. Whenever, a Web server receives an HTTP request, it responds with an HTTP response. It may respond with a static HTML page or image, send or redirect, or delegate the dynamic response generation to some other program such as CGI scripts, JSPs (Java Server Pages), Servlets. An application server exposes business logic to client applications through various protocols like HTTP, TCP-IP etc. An application server providers allows the client to access the business logic for use. An application server is used to run business logic or dynamically generating presentation code. An application server is more capable of dynamic behavior than web server. The following points depicts the differences between the Web server and Application server:
  • 21. © People Strategists www.peoplestrategists.com Slide 21 of 48 Identifying Web Container What is a Web container?
  • 22. © People Strategists www.peoplestrategists.com Slide 22 of 48 Identifying Web Container (Contd.) Web container is a Java virtual machine that supplies an implementation of the Java Servlet API. All Java servlets must exist in the Web container. Web Container activate the servlet that match to request.
  • 23. © People Strategists www.peoplestrategists.com Slide 23 of 48 The following figure depicts how the Web container handles the client request. Web server Client Web container Servlet Thread Service() doGet() <html> <body> ----------- </body> </html> Identifying Web Container (Contd.)
  • 24. © People Strategists www.peoplestrategists.com Slide 24 of 48 Execution Process of Java Servlets Following steps illustrates how a Java servlet executes: 1. The client sends request to the server. 2. The Web container, running inside the server, receives the request. 3. The Web container creates a new thread to process the request. 4. The Web container forwards the request to the servlet. 5. The Web container executes the servlet.
  • 25. © People Strategists www.peoplestrategists.com Slide 25 of 48 Execution Process of Java Servlets (Contd.) The following figure depicts the execution process of a servlet with a single request.
  • 26. © People Strategists www.peoplestrategists.com Slide 26 of 48 Execution Process of Java Servlets (Contd.) The following figure depicts the execution process of a servlet with multiple requests. Processor’s load does not increase much on execution of multiple requests.
  • 27. © People Strategists www.peoplestrategists.com Slide 27 of 48 Exploring Servlet API (Contd.) Servlet API: is used to create and manage servlets. consists of various interfaces, classes, and methods. classes and methods are available in the following packages:  javax.servlet  javax.servlet.http
  • 28. © People Strategists www.peoplestrategists.com Slide 28 of 48 Exploring Servlet API (Contd.) The following figure depicts the class hierarchy of the Servlet API. Servlet API ServletException Javax.servlet.http Servlet ServletConfig ServletContext ServletRequest ServletResponse AsyncContext Javax.servlet GenericServlet Cookie HttpServletRequest HttpServletResponse HttpSession HttpServlet Packages Classes Interfaces RequestDispatcher
  • 29. © People Strategists www.peoplestrategists.com Slide 29 of 48 The javax.servlet package: consists of the following interfaces, as described in the table. Interface Description Servlet It provides the methods that all servlets must implement. ServletConfig It provides information to the servlets during the servlet initialization. ServletContext It provides methods, which is used by the servlets to communicate with the Web container. ServletRequest It provides the client request information to the servlet. ServletResponse It helps the servlet in sending the response to the client. RequestDispatcher It receives a request from a client and sends it to any other resource, such as a servlet, an HTML page, or a JSP page. AsyncContext It provides the methods to handle multiple client requests asynchronously. Exploring Servlet API (Contd.)
  • 30. © People Strategists www.peoplestrategists.com Slide 30 of 48 The Servlet interface methods are implemented by the servlet class that extends from a GenericServlet or HttpServlet class. The following table describes the various methods defined in the Servlet interface: Exploring Servlet API (Contd.) Method Description void init(ServletConfig config) throws ServletException It is called by the servlet container to indicate to a servlet that the servlet is being placed into service. ServletConfig getServletConfig() Returns a ServletConfig object, which contains initialization and startup parameters for this servlet. String getServletInfo() Returns information about the servlet, such as author, version, and copyright. void service(ServletRequest request, ServletResponse response) throws ServletException, IOException It is Called by the servlet container to allow the servlet to respond to a request. void destroy() Called by the servlet container to indicate to a servlet that the servlet is being taken out of service.
  • 31. © People Strategists www.peoplestrategists.com Slide 31 of 48 The following table describes the various methods defined in the ServletRequest interface: Exploring Servlet API (Contd.) Method Description public String getParameter(String paramName) Returns a String object that specifies the value of a particular request parameter. public String[] getParameterValues(String paramName) Returns an array of String objects that contains all the values of the request parameter. public Enumeration getParameterNames() Returns an Enumeration object containing all the parameter names as String objects that `request contains. public String getRemoteHost() Returns a String object that specifies the full-qualified name of the computer from which the request is sent. public String getRemoteAddr() Returns a String object that specifies the IP address of the computer from which the request is sent.
  • 32. © People Strategists www.peoplestrategists.com Slide 32 of 48 The following table describes the various methods defined in the ServletResponse interface: Exploring Servlet API (Contd.) Method Description public ServletOutputStream getOutputStream() throws IOException Returns an object of the ServletOutputStream class that represents an output stream to send binary data as response. public PrintWriter getWriter() throws IOException Returns an object of the PrintWriter class that the servlet uses to send character data as response. public void setContentType(String type) Sets the MIME type for a servlet response. Some of the MIME types are text/plain, image/jpeg, and text/html.
  • 33. © People Strategists www.peoplestrategists.com Slide 33 of 48 The javax.servlet package: Consists of the following classes:  GenericServlet  ServletException The GenericServlet class defines a generic, protocol-independent servlet. The GenericServlet implements the Servlet and ServletConfig interfaces . The ServletException class defines a general exception a servlet can throw when it encounters difficulty. The ServletException class contains the following constructors:  ServletException()  ServletException(String message)  ServletException(String message, Throwable rootCause) Exploring Servlet API (Contd.)
  • 34. © People Strategists www.peoplestrategists.com Slide 34 of 48 The following code illustrates a simple example of servlet by inheriting the GenericServlet class: Exploring Servlet API (Contd.) import java.io.*; import javax.servlet.*; public class myFirstServlet extends GenericServlet{ public void service(ServletRequest req, ServletResponse res)throws IOException, ServletException { res.setContentType("text/html"); PrintWriter out=res.getWriter(); out.print("<html><body>"); out.print("<b>hello generic servlet</b>"); out.print("</body></html>"); } }
  • 35. © People Strategists www.peoplestrategists.com Slide 35 of 48 Exploring Servlet API (Contd.) The javax.servlet.http package: Provides classes and interfaces that enable you to create a servlet that communicates using the HTTP protocol. Provides the HttpServlet class to create servlets, which is an abstract class. Provides the HttpServlet class that extends the GenericServlet class and implements Serializable interface. Provides HTTP specific methods, such as doGet, doPost, and doHead. Some of the interfaces of the javax.servlet.http package are:` HttpServletRequest HttpServletResponse HttpSession
  • 36. © People Strategists www.peoplestrategists.com Slide 36 of 48 The following table describes the various methods defined in the HttpServletRequest interface: Exploring Servlet API (Contd.) Method Description public String getHeader(String fieldname) Returns the value of the request header field, such as Cache-Control and Accept-Language, specified in the parameter. public Enumeration getHeaders(String sname) Returns all the values associated with a specific request header as an enumeration of String objects. public Enumeration getHeaderNames() Returns the names of all the request headers that a servlet can access as an enumeration of String objects.
  • 37. © People Strategists www.peoplestrategists.com Slide 37 of 48 The following table describes the various methods defined in the HttpServletResponse interface: Exploring Servlet API (Contd.) Method Description void setHeader(String hname, String hvalue) Sets the value of header hname to hvalue. If the header has already been set, the new value overwrites the existing value. void setIntHeader(String hname, int hvalue) Sets the value of the header hname to the int value, hvalue. If the header has already been set, the new value overwrites the existing value. void addHeader(String hname, String hvalue) Adds a header hname with value hvalue. This method adds a new header if the header already exists. void addIntHeader(String hname, int hvalue) Adds a header hname with an int value, hvalue. boolean containsHeader(String hname) Returns true if the header hname has already been set with a specific value and false, if not. void sendRedirect(String url) Redirects a request to the specified URL.
  • 38. © People Strategists www.peoplestrategists.com Slide 38 of 48 The following table describes the various methods defined in the HttpSession interface: Exploring Servlet API (Contd.) Method Description public void setAttribute(String name, Object value) Binds the object with a name and stores the name/value pair as an attribute of the HttpSession object. If an attribute already exists, this method replaces the existing attribute. public Object getAttribute(String name) Retrieves the String object specified in the parameter, from the session object. If no object is found for the specified attribute, the getAttribute()method returns null. public Enumeration getAttributeNames() Returns an Enumeration object that contains the name of all the objects that are bound as attributes to the session object.
  • 39. © People Strategists www.peoplestrategists.com Slide 39 of 48 The following code illustrates a simple example of servlet by inheriting the HttpServlet class: Exploring Servlet API (Contd.) import java.io.IOException; import java.io.PrintWriter; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class myFirstHttpServlet extends HttpServlet { public void doGe(HttpServletRequest request, HttpServletResponse response)throws IOException{ PrintWriter out = response.getWriter(); out.println("<html>"); out.println("<body>"); out.println("<h1>Hello Servlet Get</h1>"); out.println("</body>"); out.println("</html>"); } }
  • 40. © People Strategists www.peoplestrategists.com Slide 40 of 48 Identifying Servlet Life Cycle Process the request- service() Loading servlet, Instantiate and Initialization - init() Unload servlets / Take out of service - destroy() doGet() or doPost() Calls Calls Calls The Web container maintains the life cycle of a servlet instance. The following figure depicts the life cycle of Java servlet. 1. Servlet class is loaded. 2. Servlet instance is created. 3. init()method is invoked. 4. service()method is invoked. 5. destroy()method is invoked.
  • 41. © People Strategists www.peoplestrategists.com Slide 41 of 48 Implementing a Servlet To create a servlet, you need to perform the following tasks: Create a servlet. Configure the servlet. Compile and deploy the servlet. Access the servlet using a browser application.
  • 42. © People Strategists www.peoplestrategists.com Slide 42 of 48 Creating a Servlet Servlet can be created by extending the HttpServlet or GenericServlet class. Example: Consider a scenario in which you have to create servlet that displays the current date to the user, each time the servlet is accessed. To do this, you have to create a servlet that extends from the HttpServlet class, as shown in the embedded file.
  • 43. © People Strategists www.peoplestrategists.com Slide 43 of 48 Configuring a Servlet Configuring a servlet means, associating a URL with the servlet. Servlets can be configured using either of the way: Deployment descriptor (DD) Annotations A deployment descriptor is an XML file with the name web.xml that contains configuration information of a Web application. Each Web application contains one web.xml file. The elements of the web.xml file enable you to specify: Servlet context initialization parameters of a Web application. Initialization parameter for the servlet. Mapping between a file extension and a MIME type. Mapping between a servlet and a URL pattern. The name of the listener class that responds to a servlet life cycle event.
  • 44. © People Strategists www.peoplestrategists.com Slide 44 of 48 Configuring a Servlet (Contd.) Some of the commonly used elements of the web.xml file along with their usage are: <servlet>: specifies the configuration details of all the servlets used in a Web application and contains the following sub elements:  <servlet-name>  <servlet-class> <servlet-mapping>: consists of following sub elements:  <servlet-name>  <url-pattern> <session-config> <init-param> <mime-mapping> Sample DD file:
  • 45. © People Strategists www.peoplestrategists.com Slide 45 of 48 Configuring a Servlet (Contd.) Configuring a servlet by using annotations: The javax.servlet.annotation package defines the @WebServer annotation that you can use to configure a servlet, as shown in the following sample code snippet: @WebServer(name="MyFirstServlet", urlPatterns={"/MyFirstServlet", "/MyServlet/*"}) public class MyFirstServlet extends HttpServlet { … } The @WebServer annotation is used to configure the MyFirstServlet servlet. The name attribute specifies the name of the servlet. The urlPatterns attribute is used to map the servlet with the URL patterns.
  • 46. © People Strategists www.peoplestrategists.com Slide 46 of 48 Compile and Deploy the Servlet on Server To You can compile and deploy your application using your Eclipse IDE. Finally, you can access the Web application using the URL, as shown the following code snippet: Http://Localhost:8080/myApplication/
  • 47. © People Strategists www.peoplestrategists.com Slide 47 of 48 Summary A Web page is an electronic document, which is created using HTML and is translated by the Web browser. A website is a collection of one or more Web pages, which are hosted on a Web server and are accessed by using client applications, such as a Web browser. A Web application is a program that is stored on a remote server and delivered over the Internet through a Web browser using various protocols, such as HTTP. An enterprise application is the term used to describe applications or software that a business would use to assist the organization in solving enterprise problems. Java EE is built upon the foundation of Java Platform, Standard Edition (Java SE). Web container provides a runtime environment to manage deployed Web components, such as servlets and JSP.
  • 48. © People Strategists www.peoplestrategists.com Slide 48 of 48 Summary (Contd.) Applet container provides the runtime environment for executing applets. EJB container provides a runtime environment to manage deployed EJB components. Application client container provides a runtime environment for Java EE application clients. Java Servlet API consists of two packages: javax.servlet package javax.servlet.http package The various interfaces of javax.servlet package are: ServletRequest interface ServletContext interface ServletResponse interface
  • 49. © People Strategists www.peoplestrategists.com Slide 49 of 48 Summary (Contd.) Servlet interface provides the methods that all servlets must implement. The GenericServlet class defines a generic, protocol-independent servlet. The GenericServlet implements the Servlet and ServletConfig interfaces . The ServletException class defines a general exception a servlet can throw when it encounters difficulty. The HttpServlet class is used to create a servlets that communicates using the HTTP protocol. The HttpServlet class that extends the GenericServlet class and implements Serializable interface.