SlideShare une entreprise Scribd logo
1  sur  32
 Web Container.
1. Introduction
2. Definitions:
 Web Container,
 Web Server,
 EJB Container And
 Application Server.
3. Understanding How Web Container Works.
4. Apache tomcat.
Content
Introduction
Traditional Java EE Model
A web container is responsible for managing the lifecycle of servlets, mapping a URL (Uniform
Resource Locator) to a particular servlet and ensuring that the URL requester has the correct access-
rights. A web container handles requests to servlets, java server pages (JSP) files, and other types of
files that include server-side code. The web container creates servlet instances, loads and unloads
servlets, creates and manages request and response objects, and performs other servlet-management
tasks.
Introduction
A web container (more commonly known as a servlet container) is an application implemented
on web servers to makes the implementation of 'Java Servlets' and 'Java Server Pages' possible. A
container creates a completely independent environment for running servlets and Java server pages for
the purpose of offering dynamic content to website visitors. It is primarily designed to run Java coding
on a web server.
All web containers are JEE (Java Platform Enterprise Edition) compliant. The servlets are
executed in the run time environment provided by the container through the use of JSP engine and
servlet engines. One of the most popular web containers is Apache Tomcat. It is an open source
software program developed by the Apache Software Foundation.
Introduction
 Web container,
 Web server,
 Application Server.
 EJB Container
Definition
In addition to the above explanation about Web Container, a Web Container has a couple of
meanings depending on the source. Most refer to a Web container as the part of an application server
that manages servlets, JavaServer Pages (JSP) files, and other Web-tier components. Some refer to a Web
container as the infrastructure for managing the lifecycle for Web services.
Web Container
Web server
A Web server refers to an execution infrastructure that handles HTTP requests and
responses. The primary function of web server is to store, process and deliver web pages to clients.
The communication between client and server takes place using the Hypertext Transfer Protocol
(HTTP). Pages delivered are most frequently HTML documents, which may include images, style
sheets and scripts in addition to the text content.
An application server acts as a set of components accessible to the software developer through a
standard API defined for the platform itself. For Web applications, these components are usually
performed in the same running environment as their web server(s), and their main job is to support the
construction of dynamic pages.
Application server
Enterprise JavaBeans (EJB) is one of several Java APIs for modular construction of enterprise
software. EJB is a server-side software component that encapsulates business logic of an application. An
EJB web container provides a runtime environment for web related software components,
including computer security, Java servlet lifecycle management, transaction processing, and other web
services. The EJB specification is a subset of the Java EE specification
EJB Container
Understanding Web Container
Works.
Inside the Web Container
SERVLET
Typically, a Servlet implements some control logic. For example, a Servlet might figure out
what a user typed into some text fields in a web-based form. It might then take that information
and save it to a database. Servlets are intended to be controllers. While Servlets can interact
directly with a database, they’re not really supposed to. Instead, Servlets are supposed to delegate
to a JavaBean.
Inside the Web Container
Servlet
 Act as a middle layer between requests from HTTP client (browser) and resources (databases or
applications)
 May perform any of the following tasks:
 Read
 Sent data
 Request data
 Send
 Explicit data
 Implicit response data
 Generate the results
Servlet
 init()
 Instantiate / initialize servlet
 service()
 Execute the servlet
 destroy()
 Close the resources and remove the servlet from
memory
 Valid only within the scope of a servlet’s service method or a filter’s doFilter method
 Common to recycle request objects
Filtering
Filter chain
 Sequence of filters with each filter doing some
processing and then passing on to the next in sequence
 Chain member
 Filter chain in the order of their definition in
deployment descriptor
 The last element of the chain is the target
resource/servlet
Servlet request - Request Path
 requestURI = contextPath + servletPath + pathInfo + query string
 Context Path – prefix associated with the servlet context
 Servlet path – mapping to the servlet location
 Path info – extra path info in URL if any
 Query string – request parameter name and value pairs
 Example:
 http://server.com/MyApp/MyServlet/xyz?param1=value1&param2=value2
 getContextPath - /MyApp
 getServletPath - /MyServlet
 getPathInfo - /xyz (many time it’s null)
 getQueryString - param1=value1&param2=value2
JSP
JavaServer Pages (JSP) is a technology that helps software developers create dynamically
generated web pages based on HTML, XML, or other document types. Released in 1999 by Sun
Microsystems, JSP is similar to PHP and ASP, but it uses the Java programming language.
<p>Counting to three:</p>
<% for (int i=1; i<4; i++) { %>
<p>This number is <%= i %>.</p>
<% } %>
<p>OK.</p>
Syntax:
The output displayed in the user's web browser
would be:
Counting to three:
This number is 1.
This number is 2.
This number is 3.
OK.
JSP Life Cycle
JSP Life Cycle
Apache Tomcat
1. Apache Tomcat
Apache Tomcat is a webcontainer which allows to run servlet and JavaServer Pages (JSP) based web applications. Most
of the modern Java web frameworks are based on servlets, e.g. JavaServer Faces, Struts, Spring. Apache Tomcat also provides by
default a HTTP connector on port 8080, i.e., Tomcat can also be used as HTTP server. But the performance of Tomcat is not as
good as the performance of a designated web server, like the Apache HTTP server.
2. Installation
2.1. Ubuntu Linux
For Ubuntu you can install Tomcat via the following commands.
2.2. Windows
Download the Windows installer for Tomcat7 from the Apache Tomcat Homepage and run the installer.
sudo apt-get install tomcat7
sudo apt-get install tomcat7-admin
sudo apt-get install tomcat7-docs
sudo apt-get install tomcat7-examples
3. Managing Apache Tomcat
3.1. Start Tomcat on Ubuntu (Linux)
In Ubuntu the Tomcat server is started automatically. To restart Tomcat use the following command.
3.2. Start Tomcat on Windows
To start Tomcat use tomcat7.exe in the bin directory.
3.3. Test Tomcat
The default port for Tomcat is 8080. After starting Tomcat on your local machine, you can validate if Tomcat is
running the URL:
This should show a web page similar to the following.
# Restart
sudo /etc/init.d/tomcat7 restart
# Stop
sudo /etc/init.d/tomcat7 stop
http://localhost:8080
3.4. Admin console
Tomcat provides a webbased adminstration console which can be started via the following link:
The available users can be found in the tomcat-users.xml file of the Tomcat configuration directory, i.e.,
the /etc/tomcat/tomcat-users.xml file under Ubuntu.
On Ubuntu the user for the administrator console is not created automatically, you have to add the user entry
manually to the /etc/tomcat7/tomcat-users.xml. The following listing gives an example for a user. To get more
information try to login and see the resulting error message. Once you entered a user and a password, restart the
Tomcat server to ensure your new user is activated.
The default user for the Tomcat administration console under Windows is admin with the admin password.
<role rolename="manager-gui" />
<user username="tomcat" password="s3cret" roles="manager-gui" />
http://localhost:8080/manager/html
3.5. Deployment
The standard deployment format for web applications is a .war file. If you create a war application just
put this application into the webapps folder. The next time tomcat starts it will unpack the war and make the
application available.
Web applications may require external libraries. Typically, web applications contain their own libraries but if you
want to make certain libraries available for all applications you can put them into the folder "lib" and a subfolder
below "lib". These libraries are then available for all web applications.
4. Developing Java web applications
After going through the setup you probably want to learn how to develop servlets and JSP on ab
installation directory.
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
5. Tomcat as HTTP Server
Tomcat also contains a HTTP connector which can be used to serve static HTML pages. The standard directory
which will be served is below the Tomcat webapps/ROOT installation directory. Place static content into this directory.
To allow directory browsing via Apache Tomcat change the listings parameter in the file conf/web.xml from false
to true.
As was stated earlier, the Web server tries to handle every single request that it receives.
However, when the Application server comes onto the scene, it introduces itself to the Web server and has
a conversation that goes something like this:
What Exactly Does The Web Server Plug-in Do?
Application server: Hey, Webserver..
Web Server: Yo, what’s up?
Application server: Hey, not much.
Web Server: What can I do for you?
Application server: Well, I know that you’re really great at serving up static files and all, but you’re going to
get some crazy requests for JSPs and Servlets that you won’t be able to find on your file system.
Web Server: Really? What am I going to do? I won’t be able to find any of these JSPs and Servlets, and I’ll
end up sending a bunch of 404 errors back to clients, and the clients will be pissed!
Application server: Hey, calm down. Here’s what you do: just take those requests and send them to me. I’ll
handle the request, generate some HTML, give that HTML back to you, and you can send the HTML back to
the client.
Web Server: Kewl. You do the work, but the client thinks it’s me handling the request? I like this
arrangement already. How do I know what files to send to you though?
Application server: Don’t worry. I’ll make a thorough list and write it all down in a special XML file. Just read
that file every once in a while and keep up to date on which files you need to send back to me.
Web Server: Great. But when I do get a request for an item on the list, how will I know where to send it.
Application server: Don’t worry. I’ll make a thorough list and write it all down in a special XML file. Just read
that file every once in a while and keep up to date on which files you need to send back to me.
Web Server: Great. But when I do get a request for an item on the list, how will I know where to send it.
Application server: Hey, don’t worry. I’ve got it all covered. That XML file also contains a list of which IP
addresses/port combinations to send the requests to. It’s all right there in that XML file. And if you have a
problem understanding how to use it, here’s a .dll file that explains everything to you as well. Read it every
time you start up.
Web Server: Kewl. I think this is going to be a great relationship.
THANK YOU
1. https://searchmicroservices.techtarget.com/answer/Differences-between-a-Web-container-Web-server-
servlet-container-and-an-application-server
2. https://www.theserverside.com/feature/Understanding-How-the-Application-Servers-Web-Container-Works
3. Gabriel Marquez (glmarque@us.ibm.com), Thanh Giang (tgiang@us.ibm.com), Webcontainer-WSTE_Part1,
Web Sphere Application Server level 2 support Date: September 9th, 2014.
4. https://www.google.com.hk/search?client=opera&ei=uCDeWqrmJtLGwAKphYnAAg&q=Servlet+response&oq=
Servlet+response&gs_l=psy-ab.3..0i67k1j0l9.754.2347.0.2906.11.8.0.0.0.0.443.1181.3-1j2.3.0....0...1c.1.64.psy-
ab..10.1.439....0.75FTtsGnc1M.

Contenu connexe

Tendances

Servlet.ppt
Servlet.pptServlet.ppt
Servlet.pptVMahesh5
 
Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentationguest11106b
 
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...Edureka!
 
Ibm web sphere application server interview questions
Ibm web sphere application server interview questionsIbm web sphere application server interview questions
Ibm web sphere application server interview questionspraveen_guda
 
Spring Boot & Actuators
Spring Boot & ActuatorsSpring Boot & Actuators
Spring Boot & ActuatorsVMware Tanzu
 
Understanding REST
Understanding RESTUnderstanding REST
Understanding RESTNitin Pande
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentationivpol
 
Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans Hitesh-Java
 
MVC ppt presentation
MVC ppt presentationMVC ppt presentation
MVC ppt presentationBhavin Shah
 

Tendances (20)

Servlet.ppt
Servlet.pptServlet.ppt
Servlet.ppt
 
Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentation
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
 
Spring Web MVC
Spring Web MVCSpring Web MVC
Spring Web MVC
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
Spring boot
Spring bootSpring boot
Spring boot
 
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...
 
Ibm web sphere application server interview questions
Ibm web sphere application server interview questionsIbm web sphere application server interview questions
Ibm web sphere application server interview questions
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Hibernate in Action
Hibernate in ActionHibernate in Action
Hibernate in Action
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
 
Tomcat
TomcatTomcat
Tomcat
 
Spring Boot & Actuators
Spring Boot & ActuatorsSpring Boot & Actuators
Spring Boot & Actuators
 
Understanding REST
Understanding RESTUnderstanding REST
Understanding REST
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentation
 
Java features
Java featuresJava features
Java features
 
Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans
 
MVC ppt presentation
MVC ppt presentationMVC ppt presentation
MVC ppt presentation
 
Laravel Lab
Laravel LabLaravel Lab
Laravel Lab
 

Similaire à Web container and Apache Tomcat

Web Application Deployment
Web Application DeploymentWeb Application Deployment
Web Application Deploymentelliando dias
 
UNIT-3 Servlet
UNIT-3 ServletUNIT-3 Servlet
UNIT-3 Servletssbd6985
 
Chapter 3 servlet & jsp
Chapter 3 servlet & jspChapter 3 servlet & jsp
Chapter 3 servlet & jspJafar Nesargi
 
Jsp and Servlets
Jsp and ServletsJsp and Servlets
Jsp and ServletsRaghu nath
 
Web Tech Java Servlet Update1
Web Tech   Java Servlet Update1Web Tech   Java Servlet Update1
Web Tech Java Servlet Update1vikram singh
 
An Introduction To Java Web Technology
An Introduction To Java Web TechnologyAn Introduction To Java Web Technology
An Introduction To Java Web Technologyvikram singh
 
Introduction to the Servlet / JSP course
Introduction to the Servlet / JSP course Introduction to the Servlet / JSP course
Introduction to the Servlet / JSP course JavaEE Trainers
 
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.pptsindhu991994
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)slire
 
Http Server Programming in JAVA - Handling http requests and responses
Http Server Programming in JAVA - Handling http requests and responsesHttp Server Programming in JAVA - Handling http requests and responses
Http Server Programming in JAVA - Handling http requests and responsesbharathiv53
 
Java Servlets
Java ServletsJava Servlets
Java ServletsNitin Pai
 
JSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESJSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESYoga Raja
 
java Servlet technology
java Servlet technologyjava Servlet technology
java Servlet technologyTanmoy Barman
 
1 java servlets and jsp
1   java servlets and jsp1   java servlets and jsp
1 java servlets and jspAnkit Minocha
 

Similaire à Web container and Apache Tomcat (20)

Unit5 servlets
Unit5 servletsUnit5 servlets
Unit5 servlets
 
Web Application Deployment
Web Application DeploymentWeb Application Deployment
Web Application Deployment
 
UNIT-3 Servlet
UNIT-3 ServletUNIT-3 Servlet
UNIT-3 Servlet
 
Servlet by Rj
Servlet by RjServlet by Rj
Servlet by Rj
 
Chapter 3 servlet & jsp
Chapter 3 servlet & jspChapter 3 servlet & jsp
Chapter 3 servlet & jsp
 
Jsp and Servlets
Jsp and ServletsJsp and Servlets
Jsp and Servlets
 
Unit 4 web technology uptu
Unit 4 web technology uptuUnit 4 web technology uptu
Unit 4 web technology uptu
 
Unit 4 1 web technology uptu
Unit 4 1 web technology uptuUnit 4 1 web technology uptu
Unit 4 1 web technology uptu
 
Web Tech Java Servlet Update1
Web Tech   Java Servlet Update1Web Tech   Java Servlet Update1
Web Tech Java Servlet Update1
 
An Introduction To Java Web Technology
An Introduction To Java Web TechnologyAn Introduction To Java Web Technology
An Introduction To Java Web Technology
 
Introduction to the Servlet / JSP course
Introduction to the Servlet / JSP course Introduction to the Servlet / JSP course
Introduction to the Servlet / JSP course
 
Servlets
ServletsServlets
Servlets
 
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
 
Http Server Programming in JAVA - Handling http requests and responses
Http Server Programming in JAVA - Handling http requests and responsesHttp Server Programming in JAVA - Handling http requests and responses
Http Server Programming in JAVA - Handling http requests and responses
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
JSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESJSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGES
 
java Servlet technology
java Servlet technologyjava Servlet technology
java Servlet technology
 
1 java servlets and jsp
1   java servlets and jsp1   java servlets and jsp
1 java servlets and jsp
 
Java Servlets & JSP
Java Servlets & JSPJava Servlets & JSP
Java Servlets & JSP
 

Plus de Auwal Amshi

Conceptual Design of LiFi Audio Transmission Using Pre-Programmed Modules
Conceptual Design of LiFi Audio Transmission Using Pre-Programmed ModulesConceptual Design of LiFi Audio Transmission Using Pre-Programmed Modules
Conceptual Design of LiFi Audio Transmission Using Pre-Programmed ModulesAuwal Amshi
 
Challenges for routing in wireless sensor networks
Challenges for routing in wireless sensor networksChallenges for routing in wireless sensor networks
Challenges for routing in wireless sensor networksAuwal Amshi
 
Routing in Opportunistic Networks
Routing in Opportunistic NetworksRouting in Opportunistic Networks
Routing in Opportunistic NetworksAuwal Amshi
 
Audio Transmission using LED
Audio Transmission using LEDAudio Transmission using LED
Audio Transmission using LEDAuwal Amshi
 
comparative study software quality models
comparative study  software quality models comparative study  software quality models
comparative study software quality models Auwal Amshi
 
Li fi and its application
Li fi and its applicationLi fi and its application
Li fi and its applicationAuwal Amshi
 

Plus de Auwal Amshi (6)

Conceptual Design of LiFi Audio Transmission Using Pre-Programmed Modules
Conceptual Design of LiFi Audio Transmission Using Pre-Programmed ModulesConceptual Design of LiFi Audio Transmission Using Pre-Programmed Modules
Conceptual Design of LiFi Audio Transmission Using Pre-Programmed Modules
 
Challenges for routing in wireless sensor networks
Challenges for routing in wireless sensor networksChallenges for routing in wireless sensor networks
Challenges for routing in wireless sensor networks
 
Routing in Opportunistic Networks
Routing in Opportunistic NetworksRouting in Opportunistic Networks
Routing in Opportunistic Networks
 
Audio Transmission using LED
Audio Transmission using LEDAudio Transmission using LED
Audio Transmission using LED
 
comparative study software quality models
comparative study  software quality models comparative study  software quality models
comparative study software quality models
 
Li fi and its application
Li fi and its applicationLi fi and its application
Li fi and its application
 

Dernier

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
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
 
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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Dernier (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
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...
 
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...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Web container and Apache Tomcat

  • 2. 1. Introduction 2. Definitions:  Web Container,  Web Server,  EJB Container And  Application Server. 3. Understanding How Web Container Works. 4. Apache tomcat. Content
  • 4. A web container is responsible for managing the lifecycle of servlets, mapping a URL (Uniform Resource Locator) to a particular servlet and ensuring that the URL requester has the correct access- rights. A web container handles requests to servlets, java server pages (JSP) files, and other types of files that include server-side code. The web container creates servlet instances, loads and unloads servlets, creates and manages request and response objects, and performs other servlet-management tasks. Introduction
  • 5. A web container (more commonly known as a servlet container) is an application implemented on web servers to makes the implementation of 'Java Servlets' and 'Java Server Pages' possible. A container creates a completely independent environment for running servlets and Java server pages for the purpose of offering dynamic content to website visitors. It is primarily designed to run Java coding on a web server. All web containers are JEE (Java Platform Enterprise Edition) compliant. The servlets are executed in the run time environment provided by the container through the use of JSP engine and servlet engines. One of the most popular web containers is Apache Tomcat. It is an open source software program developed by the Apache Software Foundation. Introduction
  • 6.  Web container,  Web server,  Application Server.  EJB Container Definition
  • 7. In addition to the above explanation about Web Container, a Web Container has a couple of meanings depending on the source. Most refer to a Web container as the part of an application server that manages servlets, JavaServer Pages (JSP) files, and other Web-tier components. Some refer to a Web container as the infrastructure for managing the lifecycle for Web services. Web Container
  • 8. Web server A Web server refers to an execution infrastructure that handles HTTP requests and responses. The primary function of web server is to store, process and deliver web pages to clients. The communication between client and server takes place using the Hypertext Transfer Protocol (HTTP). Pages delivered are most frequently HTML documents, which may include images, style sheets and scripts in addition to the text content.
  • 9. An application server acts as a set of components accessible to the software developer through a standard API defined for the platform itself. For Web applications, these components are usually performed in the same running environment as their web server(s), and their main job is to support the construction of dynamic pages. Application server
  • 10. Enterprise JavaBeans (EJB) is one of several Java APIs for modular construction of enterprise software. EJB is a server-side software component that encapsulates business logic of an application. An EJB web container provides a runtime environment for web related software components, including computer security, Java servlet lifecycle management, transaction processing, and other web services. The EJB specification is a subset of the Java EE specification EJB Container
  • 12. Inside the Web Container SERVLET Typically, a Servlet implements some control logic. For example, a Servlet might figure out what a user typed into some text fields in a web-based form. It might then take that information and save it to a database. Servlets are intended to be controllers. While Servlets can interact directly with a database, they’re not really supposed to. Instead, Servlets are supposed to delegate to a JavaBean.
  • 13. Inside the Web Container
  • 14. Servlet  Act as a middle layer between requests from HTTP client (browser) and resources (databases or applications)  May perform any of the following tasks:  Read  Sent data  Request data  Send  Explicit data  Implicit response data  Generate the results
  • 15. Servlet  init()  Instantiate / initialize servlet  service()  Execute the servlet  destroy()  Close the resources and remove the servlet from memory  Valid only within the scope of a servlet’s service method or a filter’s doFilter method  Common to recycle request objects
  • 17. Filter chain  Sequence of filters with each filter doing some processing and then passing on to the next in sequence  Chain member  Filter chain in the order of their definition in deployment descriptor  The last element of the chain is the target resource/servlet
  • 18. Servlet request - Request Path  requestURI = contextPath + servletPath + pathInfo + query string  Context Path – prefix associated with the servlet context  Servlet path – mapping to the servlet location  Path info – extra path info in URL if any  Query string – request parameter name and value pairs  Example:  http://server.com/MyApp/MyServlet/xyz?param1=value1&param2=value2  getContextPath - /MyApp  getServletPath - /MyServlet  getPathInfo - /xyz (many time it’s null)  getQueryString - param1=value1&param2=value2
  • 19. JSP JavaServer Pages (JSP) is a technology that helps software developers create dynamically generated web pages based on HTML, XML, or other document types. Released in 1999 by Sun Microsystems, JSP is similar to PHP and ASP, but it uses the Java programming language. <p>Counting to three:</p> <% for (int i=1; i<4; i++) { %> <p>This number is <%= i %>.</p> <% } %> <p>OK.</p> Syntax: The output displayed in the user's web browser would be: Counting to three: This number is 1. This number is 2. This number is 3. OK.
  • 23. 1. Apache Tomcat Apache Tomcat is a webcontainer which allows to run servlet and JavaServer Pages (JSP) based web applications. Most of the modern Java web frameworks are based on servlets, e.g. JavaServer Faces, Struts, Spring. Apache Tomcat also provides by default a HTTP connector on port 8080, i.e., Tomcat can also be used as HTTP server. But the performance of Tomcat is not as good as the performance of a designated web server, like the Apache HTTP server. 2. Installation 2.1. Ubuntu Linux For Ubuntu you can install Tomcat via the following commands. 2.2. Windows Download the Windows installer for Tomcat7 from the Apache Tomcat Homepage and run the installer. sudo apt-get install tomcat7 sudo apt-get install tomcat7-admin sudo apt-get install tomcat7-docs sudo apt-get install tomcat7-examples
  • 24. 3. Managing Apache Tomcat 3.1. Start Tomcat on Ubuntu (Linux) In Ubuntu the Tomcat server is started automatically. To restart Tomcat use the following command. 3.2. Start Tomcat on Windows To start Tomcat use tomcat7.exe in the bin directory. 3.3. Test Tomcat The default port for Tomcat is 8080. After starting Tomcat on your local machine, you can validate if Tomcat is running the URL: This should show a web page similar to the following. # Restart sudo /etc/init.d/tomcat7 restart # Stop sudo /etc/init.d/tomcat7 stop http://localhost:8080
  • 25. 3.4. Admin console Tomcat provides a webbased adminstration console which can be started via the following link: The available users can be found in the tomcat-users.xml file of the Tomcat configuration directory, i.e., the /etc/tomcat/tomcat-users.xml file under Ubuntu. On Ubuntu the user for the administrator console is not created automatically, you have to add the user entry manually to the /etc/tomcat7/tomcat-users.xml. The following listing gives an example for a user. To get more information try to login and see the resulting error message. Once you entered a user and a password, restart the Tomcat server to ensure your new user is activated. The default user for the Tomcat administration console under Windows is admin with the admin password. <role rolename="manager-gui" /> <user username="tomcat" password="s3cret" roles="manager-gui" /> http://localhost:8080/manager/html
  • 26. 3.5. Deployment The standard deployment format for web applications is a .war file. If you create a war application just put this application into the webapps folder. The next time tomcat starts it will unpack the war and make the application available. Web applications may require external libraries. Typically, web applications contain their own libraries but if you want to make certain libraries available for all applications you can put them into the folder "lib" and a subfolder below "lib". These libraries are then available for all web applications. 4. Developing Java web applications After going through the setup you probably want to learn how to develop servlets and JSP on ab installation directory.
  • 27. <servlet> <servlet-name>default</servlet-name> <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class> <init-param> <param-name>debug</param-name> <param-value>0</param-value> </init-param> <init-param> <param-name>listings</param-name> <param-value>true</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> 5. Tomcat as HTTP Server Tomcat also contains a HTTP connector which can be used to serve static HTML pages. The standard directory which will be served is below the Tomcat webapps/ROOT installation directory. Place static content into this directory. To allow directory browsing via Apache Tomcat change the listings parameter in the file conf/web.xml from false to true.
  • 28. As was stated earlier, the Web server tries to handle every single request that it receives. However, when the Application server comes onto the scene, it introduces itself to the Web server and has a conversation that goes something like this: What Exactly Does The Web Server Plug-in Do?
  • 29. Application server: Hey, Webserver.. Web Server: Yo, what’s up? Application server: Hey, not much. Web Server: What can I do for you? Application server: Well, I know that you’re really great at serving up static files and all, but you’re going to get some crazy requests for JSPs and Servlets that you won’t be able to find on your file system. Web Server: Really? What am I going to do? I won’t be able to find any of these JSPs and Servlets, and I’ll end up sending a bunch of 404 errors back to clients, and the clients will be pissed! Application server: Hey, calm down. Here’s what you do: just take those requests and send them to me. I’ll handle the request, generate some HTML, give that HTML back to you, and you can send the HTML back to the client. Web Server: Kewl. You do the work, but the client thinks it’s me handling the request? I like this arrangement already. How do I know what files to send to you though?
  • 30. Application server: Don’t worry. I’ll make a thorough list and write it all down in a special XML file. Just read that file every once in a while and keep up to date on which files you need to send back to me. Web Server: Great. But when I do get a request for an item on the list, how will I know where to send it. Application server: Don’t worry. I’ll make a thorough list and write it all down in a special XML file. Just read that file every once in a while and keep up to date on which files you need to send back to me. Web Server: Great. But when I do get a request for an item on the list, how will I know where to send it. Application server: Hey, don’t worry. I’ve got it all covered. That XML file also contains a list of which IP addresses/port combinations to send the requests to. It’s all right there in that XML file. And if you have a problem understanding how to use it, here’s a .dll file that explains everything to you as well. Read it every time you start up. Web Server: Kewl. I think this is going to be a great relationship.
  • 32. 1. https://searchmicroservices.techtarget.com/answer/Differences-between-a-Web-container-Web-server- servlet-container-and-an-application-server 2. https://www.theserverside.com/feature/Understanding-How-the-Application-Servers-Web-Container-Works 3. Gabriel Marquez (glmarque@us.ibm.com), Thanh Giang (tgiang@us.ibm.com), Webcontainer-WSTE_Part1, Web Sphere Application Server level 2 support Date: September 9th, 2014. 4. https://www.google.com.hk/search?client=opera&ei=uCDeWqrmJtLGwAKphYnAAg&q=Servlet+response&oq= Servlet+response&gs_l=psy-ab.3..0i67k1j0l9.754.2347.0.2906.11.8.0.0.0.0.443.1181.3-1j2.3.0....0...1c.1.64.psy- ab..10.1.439....0.75FTtsGnc1M.