SlideShare une entreprise Scribd logo
1  sur  35
Télécharger pour lire hors ligne
Servlet Life Cycle
Servlet Life Cycle
• A servlet life cycle can be defined as the entire
process from its creation till the destruction.
• The servlet is initialized by calling the init()
method.
• The servlet calls service() method to process a
client's request.
• The servlet is terminated by calling the
destroy() method.
• Finally, servlet is garbage collected by the
garbage collector of the JVM.
Servlet life cycle contains five steps:
1. Loading of Servlet
2. Creating instance of Servlet
3. Invoke init() once
4. Invoke service() repeatedly for each client
request
5. Invoke destroy()
3
Step 1: Loading of Servlet
When the web server (e.g. Apache Tomcat) starts
up, the servlet container deploy and loads all the
servlets.
Step 2: Creating instance of Servlet
Once all the Servlet classes loaded, the servlet
container creates instances of each servlet class.
Servlet container creates only once instance per
servlet class and all the requests to the servlet are
executed on the same servlet instance.
Step 3: Invoke init() method
Once all the servlet classes are instantiated, the
init() method is invoked for each instantiated
servlet. 4
Step 4: Invoke service() method
Each time the web server receives a request for servlet,
it spawns a new thread that calls service() method.
If the servlet is GenericServlet then the request is
served by the service() method itself,
if the servlet is HttpServlet then service() method
receives the request and dispatches it to the correct
handler method based on the type of request.
Step 5: Invoke destroy() method
When servlet container shuts down(this usually
happens when we stop the web server), it unloads all
the servlets and calls destroy() method for each
initialized servlets. 5
Architecture Diagram:
The following figure depicts a typical servlet life-cycle
scenario.
First the HTTP requests coming to the server
are delegated to the servlet container.
The servlet container loads the servlet before
invoking the service() method.
Then the servlet container handles multiple
requests by spawning multiple threads, each
thread executing the service() method of a
single instance of the servlet.
6
7
Servlet life cycle
How Servlet Works?
1) When the web server (e.g. Apache Tomcat) starts up,
the servlet container deploy and loads all the servlets.
2) Once the servlet is loaded, the servlet container
creates the instance of servlet class. For each
instantiated servlet, its init() method is invoked.
3) Client (user browser) sends an Http request to web
server on a certain port. Each time the web server
receives a request, the servlet container creates
HttpServletRequest and HttpServletResponse objects.
The HttpServletRequest object provides the access to
the request information and the HttpServletResponse
object allows us to format and change the http
response before sending it to the client. 9
The init() method :
• The init() method is designed to be called only
once.
• It is called when the servlet is first created,
and not called again for each user request.
• So, it is used for one-time initializations, just
as with the init() method of applets.
• The servlet is normally created when a user
first invokes a URL corresponding to the
servlet.
The init() method
public void init() throws ServletException
{
// Initialization code...
}
The service() method :
• The service() method is the main method
to perform the actual task.
• The servlet container (i.e. web server)
calls the service() method to handle
requests coming from the client(
browsers) and to write the formatted
response back to the client.
• Each time if the server receives a request for a
servlet, the server issues a new thread and
calls service.
• The service() method checks the HTTP request
type (GET, POST, PUT, DELETE, etc.) and calls
doGet, doPost, doPut, doDelete, etc. methods
as appropriate.
signature of service()
public void service(ServletRequest request,
ServletResponse response) throws
ServletException, IOException
{
}
• The service() method is called by the
container and service method invokes doGet,
doPost, doPut, doDelete, etc. methods as
appropriate.
• So you have nothing to do with service()
method but you override either doGet() or
doPost() depending on what type of request
you receive from the client.
• The doGet() and doPost() are most frequently
used methods with in each service request.
signature of the doGet() method
public void doGet(HttpServletRequest
request, HttpServletResponse response)
throws ServletException, IOException
{
// Servlet code
}
signature of the doPost() method
public void doPost(HttpServletRequest request,
HttpServletResponse response) throws
ServletException, IOException
{
// Servlet code
}
The destroy() method :
• The destroy() method is called only once at the
end of the life cycle of a servlet.
• This method gives your servlet a chance to close
database connections, halt background threads,
write cookie lists or hit counts to disk, and
perform other such cleanup activities.
• After the destroy() method is called, the servlet
object is marked for garbage collection. The
destroy method definition looks like this:
• public void destroy() { // Finalization code... }
NetBeans IDE
Select new project from File menu
Select Java Web
Select Web Application and Click Next
Give the Application Name and click next
Server Settings & Click Finish button
The basic terminology used in servlet
• HTTP
• HTTP Request Types
• Difference between Get and Post method
• Container
• Server and Difference between web server
and application server
• Content Type
• Introduction of XML
• Deployment
HTTP (Hyper Text Transfer Protocol)
• Http is the protocol that allows web servers
and browsers to exchange data over the web.
• It is a request response protocol.
• Http uses reliable TCP connections by default
on TCP port 80.
• It is stateless means each request is
considered as the new request. In other
words, server doesn't recognize the user by
default.
HTTP
Http Request Methods
• Every request has a header that tells the status of the client.
• There are many request methods. Get and Post requests are
mostly used.
• The http request methods are:
• GET
• POST
• HEAD
• PUT
• DELETE
• OPTIONS
• TRACE
HTTP Request Description
GET Asks to get the resource at the requested URL.
POST
Asks the server to accept the body info attached. It is
like GET request with extra info sent with the request.
HEAD
Asks for only the header part of whatever a GET would
return. Just like GET but with no body.
TRACE
Asks for the loopback of the request message, for
testing or troubleshooting.
PUT
Says to put the enclosed info (the body) at the
requested URL.
DELETE Says to delete the resource at the requested URL.
OPTIONS
Asks for a list of the HTTP methods to which the thing
at the request URL can respond
What is the difference between Get and Post?
GET POST
1) In case of Get request, only limited
amount of data can be sent because
data is sent in header.
In case of post request, large amount
of data can be sent because data is
sent in body.
2) Get request is not secured because
data is exposed in URL bar.
Post request is secured because data is
not exposed in URL bar.
3) Get request can be bookmarked Post request cannot be bookmarked
4) Get request is idempotent. It means
second request will be ignored until
response of first request is delivered.
Post request is non-idempotent
5) Get request is more efficient and
used more than Post
Post request is less efficient and used
less than get.
Container
• It provides runtime environment for Java Web
or JavaEE (J2EE) applications.
• It performs many operations that are given
below:
• Life Cycle Management
• Multithreaded support
• Object Pooling
• Security etc.
Server
• It is a running program or software that
provides services.
• There are two types of servers:
• Web Server
• Application Server
• Web Server
• Web server contains only web or servlet container. It can be
used for servlet, jsp, struts, jsf etc. It can't be used for EJB.
• Example of Web Servers are: Apache Tomcat and Resin.
• Application Server
• Application server contains Web and EJB containers. It can be
used for servlet, jsp, struts, jsf, ejb etc.
• Example of Application Servers are:
• JBoss Open-source server from JBoss community.
• Glassfish provided by Sun Microsystem. Now acquired by
Oracle.
• Weblogic provided by Oracle. It more secured.
• Websphere provided by IBM.
Content Type
• Content Type is also known as MIME (Multipurpose internet Mail
Extension) Type. It is a HTTP header that provides the description about
what are you sending to the browser.
• There are many content types:
• text/html
• text/plain
• application/msword
• application/vnd.ms-excel
• application/jar
• application/pdf
• application/octet-stream
• application/x-zip
• images/jpeg
• video/quicktime etc.

Contenu connexe

Similaire à servlet_lifecycle.pdf (20)

Servlet.ppt
Servlet.pptServlet.ppt
Servlet.ppt
 
Servlet1.ppt
Servlet1.pptServlet1.ppt
Servlet1.ppt
 
Web Technologies -- Servlets 4 unit slides
Web Technologies -- Servlets   4 unit slidesWeb Technologies -- Servlets   4 unit slides
Web Technologies -- Servlets 4 unit slides
 
Servlet ppt by vikas jagtap
Servlet ppt by vikas jagtapServlet ppt by vikas jagtap
Servlet ppt by vikas jagtap
 
ajava unit 1.pptx
ajava unit 1.pptxajava unit 1.pptx
ajava unit 1.pptx
 
JAVA Servlets
JAVA ServletsJAVA Servlets
JAVA Servlets
 
Servlets
ServletsServlets
Servlets
 
SERVIET
SERVIETSERVIET
SERVIET
 
Servlet and servlet life cycle
Servlet and servlet life cycleServlet and servlet life cycle
Servlet and servlet life cycle
 
Wt unit 3
Wt unit 3 Wt unit 3
Wt unit 3
 
IT2255 Web Essentials - Unit V Servlets and Database Connectivity
IT2255 Web Essentials - Unit V Servlets and Database ConnectivityIT2255 Web Essentials - Unit V Servlets and Database Connectivity
IT2255 Web Essentials - Unit V Servlets and Database Connectivity
 
Dynamic content generation
Dynamic content generationDynamic content generation
Dynamic content generation
 
J2EE : Java servlet and its types, environment
J2EE : Java servlet and its types, environmentJ2EE : Java servlet and its types, environment
J2EE : Java servlet and its types, environment
 
Servlet.pptx
Servlet.pptxServlet.pptx
Servlet.pptx
 
Servlet.pptx
Servlet.pptxServlet.pptx
Servlet.pptx
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Wt unit 3 server side technology
Wt unit 3 server side technologyWt unit 3 server side technology
Wt unit 3 server side technology
 
Wt unit 3 server side technology
Wt unit 3 server side technologyWt unit 3 server side technology
Wt unit 3 server side technology
 
Servlet
Servlet Servlet
Servlet
 
Lecture 2: Servlets
Lecture 2:  ServletsLecture 2:  Servlets
Lecture 2: Servlets
 

Dernier

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 

Dernier (20)

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 

servlet_lifecycle.pdf

  • 2. Servlet Life Cycle • A servlet life cycle can be defined as the entire process from its creation till the destruction. • The servlet is initialized by calling the init() method. • The servlet calls service() method to process a client's request. • The servlet is terminated by calling the destroy() method. • Finally, servlet is garbage collected by the garbage collector of the JVM.
  • 3. Servlet life cycle contains five steps: 1. Loading of Servlet 2. Creating instance of Servlet 3. Invoke init() once 4. Invoke service() repeatedly for each client request 5. Invoke destroy() 3
  • 4. Step 1: Loading of Servlet When the web server (e.g. Apache Tomcat) starts up, the servlet container deploy and loads all the servlets. Step 2: Creating instance of Servlet Once all the Servlet classes loaded, the servlet container creates instances of each servlet class. Servlet container creates only once instance per servlet class and all the requests to the servlet are executed on the same servlet instance. Step 3: Invoke init() method Once all the servlet classes are instantiated, the init() method is invoked for each instantiated servlet. 4
  • 5. Step 4: Invoke service() method Each time the web server receives a request for servlet, it spawns a new thread that calls service() method. If the servlet is GenericServlet then the request is served by the service() method itself, if the servlet is HttpServlet then service() method receives the request and dispatches it to the correct handler method based on the type of request. Step 5: Invoke destroy() method When servlet container shuts down(this usually happens when we stop the web server), it unloads all the servlets and calls destroy() method for each initialized servlets. 5
  • 6. Architecture Diagram: The following figure depicts a typical servlet life-cycle scenario. First the HTTP requests coming to the server are delegated to the servlet container. The servlet container loads the servlet before invoking the service() method. Then the servlet container handles multiple requests by spawning multiple threads, each thread executing the service() method of a single instance of the servlet. 6
  • 7. 7
  • 9. How Servlet Works? 1) When the web server (e.g. Apache Tomcat) starts up, the servlet container deploy and loads all the servlets. 2) Once the servlet is loaded, the servlet container creates the instance of servlet class. For each instantiated servlet, its init() method is invoked. 3) Client (user browser) sends an Http request to web server on a certain port. Each time the web server receives a request, the servlet container creates HttpServletRequest and HttpServletResponse objects. The HttpServletRequest object provides the access to the request information and the HttpServletResponse object allows us to format and change the http response before sending it to the client. 9
  • 10. The init() method : • The init() method is designed to be called only once. • It is called when the servlet is first created, and not called again for each user request. • So, it is used for one-time initializations, just as with the init() method of applets. • The servlet is normally created when a user first invokes a URL corresponding to the servlet.
  • 11. The init() method public void init() throws ServletException { // Initialization code... }
  • 12. The service() method : • The service() method is the main method to perform the actual task. • The servlet container (i.e. web server) calls the service() method to handle requests coming from the client( browsers) and to write the formatted response back to the client.
  • 13. • Each time if the server receives a request for a servlet, the server issues a new thread and calls service. • The service() method checks the HTTP request type (GET, POST, PUT, DELETE, etc.) and calls doGet, doPost, doPut, doDelete, etc. methods as appropriate.
  • 14. signature of service() public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException { }
  • 15. • The service() method is called by the container and service method invokes doGet, doPost, doPut, doDelete, etc. methods as appropriate. • So you have nothing to do with service() method but you override either doGet() or doPost() depending on what type of request you receive from the client. • The doGet() and doPost() are most frequently used methods with in each service request.
  • 16. signature of the doGet() method public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // Servlet code }
  • 17. signature of the doPost() method public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // Servlet code }
  • 18. The destroy() method : • The destroy() method is called only once at the end of the life cycle of a servlet. • This method gives your servlet a chance to close database connections, halt background threads, write cookie lists or hit counts to disk, and perform other such cleanup activities. • After the destroy() method is called, the servlet object is marked for garbage collection. The destroy method definition looks like this: • public void destroy() { // Finalization code... }
  • 20. Select new project from File menu
  • 22. Select Web Application and Click Next
  • 23. Give the Application Name and click next
  • 24. Server Settings & Click Finish button
  • 25.
  • 26. The basic terminology used in servlet • HTTP • HTTP Request Types • Difference between Get and Post method • Container • Server and Difference between web server and application server • Content Type • Introduction of XML • Deployment
  • 27. HTTP (Hyper Text Transfer Protocol) • Http is the protocol that allows web servers and browsers to exchange data over the web. • It is a request response protocol. • Http uses reliable TCP connections by default on TCP port 80. • It is stateless means each request is considered as the new request. In other words, server doesn't recognize the user by default.
  • 28. HTTP
  • 29. Http Request Methods • Every request has a header that tells the status of the client. • There are many request methods. Get and Post requests are mostly used. • The http request methods are: • GET • POST • HEAD • PUT • DELETE • OPTIONS • TRACE
  • 30. HTTP Request Description GET Asks to get the resource at the requested URL. POST Asks the server to accept the body info attached. It is like GET request with extra info sent with the request. HEAD Asks for only the header part of whatever a GET would return. Just like GET but with no body. TRACE Asks for the loopback of the request message, for testing or troubleshooting. PUT Says to put the enclosed info (the body) at the requested URL. DELETE Says to delete the resource at the requested URL. OPTIONS Asks for a list of the HTTP methods to which the thing at the request URL can respond
  • 31. What is the difference between Get and Post? GET POST 1) In case of Get request, only limited amount of data can be sent because data is sent in header. In case of post request, large amount of data can be sent because data is sent in body. 2) Get request is not secured because data is exposed in URL bar. Post request is secured because data is not exposed in URL bar. 3) Get request can be bookmarked Post request cannot be bookmarked 4) Get request is idempotent. It means second request will be ignored until response of first request is delivered. Post request is non-idempotent 5) Get request is more efficient and used more than Post Post request is less efficient and used less than get.
  • 32. Container • It provides runtime environment for Java Web or JavaEE (J2EE) applications. • It performs many operations that are given below: • Life Cycle Management • Multithreaded support • Object Pooling • Security etc.
  • 33. Server • It is a running program or software that provides services. • There are two types of servers: • Web Server • Application Server
  • 34. • Web Server • Web server contains only web or servlet container. It can be used for servlet, jsp, struts, jsf etc. It can't be used for EJB. • Example of Web Servers are: Apache Tomcat and Resin. • Application Server • Application server contains Web and EJB containers. It can be used for servlet, jsp, struts, jsf, ejb etc. • Example of Application Servers are: • JBoss Open-source server from JBoss community. • Glassfish provided by Sun Microsystem. Now acquired by Oracle. • Weblogic provided by Oracle. It more secured. • Websphere provided by IBM.
  • 35. Content Type • Content Type is also known as MIME (Multipurpose internet Mail Extension) Type. It is a HTTP header that provides the description about what are you sending to the browser. • There are many content types: • text/html • text/plain • application/msword • application/vnd.ms-excel • application/jar • application/pdf • application/octet-stream • application/x-zip • images/jpeg • video/quicktime etc.