SlideShare a Scribd company logo
1 of 36
Apache TomcatApache Tomcat
Representation and Management of
Data on the Web
What is Tomcat?What is Tomcat?
• Tomcat is a Servlet container (Web server that interacts
with Servlets) developed under the Jakarta Project of
Apache Software Foundation
• Tomcat implements the Servlet and the Java Server
Pages (JSP) specifications of Sun Microsystems
• Tomcat is an open-source, non commercial project
- Licensed under the Apache Software License
• Tomcat is written in Java (OS independent)
A Servlet ExampleA Servlet Example
public class HelloWorld extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("<html><head><title>Hello</title></head>");
out.println("<body>");
out.println("<h2>" + new java.util.Date() + "</h2>");
out.println("<h1>Hello World</h1></body></html>");
}
} HelloWorld.java
http://localhost/dbi/hello
A JSP ExampleA JSP Example
<html>
<head>
<title>Hello World</title>
</head>
<body>
<h2><%= new java.util.Date() %></h2>
<h1>Hello World</h1>
</body>
</html> hello.jsp
http://localhost/dbi/hello.jsp
Another JSP ExampleAnother JSP Example
<html>
<head><title>Numbers</title></head>
<body>
<h1>The numbers 1 to 10:</h1>
<ul>
<% int i;
for (i=1; i<=10; ++i) { %>
<li>Number <%=i%> </li>
<%}%>
</ul>
</body>
</html> numbers.jsp
http://localhost/dbi/numbers.jsp
Running TomcatRunning Tomcat
Tomcat Directory StructureTomcat Directory Structure
Base and Home DirectoriesBase and Home Directories
• The directory TOMCAT-HOME contains
executables and libraries required for the server
launching, running and stopping
- This directory is placed under /usr/local/…
• The directory TOMCAT-BASE contains the
Web-site content, Web applications and
configuration data
- This directory is placed under your home directory
Installing TomcatInstalling Tomcat
• Create a directory for tomcat base
- For example: mkdir ~/tomcat-base
• Set the environment variable CATALINA_BASE to
your tomcat-base directory
- For example: setenv CATALINA_BASE ~/tomcat-base
- Insert this line into your .cshrc file
• Run ~dbi/tomcat/bin/setup
• $CATALINA_BASE is now a regular Tomcat base
directory, and Tomcat is ready to run
Running TomcatRunning Tomcat
• To start tomcat use ~dbi/tomcat/bin/catalina run
• Or, in background, ~dbi/tomcat/bin/catalina start
• To stop tomcat use ~dbi/tomcat/bin/catalina stop
• To see the default page of Tomcat from your browser
use the URL http://<machine-name>:<port>/
- machine-name is the name of the machine on which Tomcat
runs and port is the port you chose for Tomcat
• You can also use http://localhost:<port>/ if your
browser runs on the same machine as Tomcat
From Scratch to ServerFrom Scratch to Server
Choosing a port for TomcatChoosing a port for Tomcat
• In the file $CATALINA_HOME/conf/server.xml you
will find the element Connector of Service “Catalina”
• Choose a port (greater than 1024) and change the value
of the port attribute to your chosen one:
<Server>
…
<Service name="Catalina”>
<Connector port="8090"/>
…
</Service>
…
</Server>
Creating Web ApplicationsCreating Web Applications
Creating Web ApplicationsCreating Web Applications
• A Web application is a self-contained subtree of
the Web site
• A Web application usually contains several Web
resources like HTML files, Servlets, JSP files,
and other resources like Database tables
• Each Web application has its own subdirectory
under the directory
$CATALINA_BASE/webapps/
The Directory Structure of a WebThe Directory Structure of a Web
ApplicationApplication
• Tomcat automatically identifies a directory
$CATALINA_BASE/webapps/myApp/ with
the relative URL /myApp/
• For example, a file named index.html in myApp
is mapped to by the following URLs:
http://machine:port/myApp/index.html
http://machine:port/myApp/
The Directory Structure of a WebThe Directory Structure of a Web
ApplicationApplication
• You can also use subdirectories under myApp
• For example: the file myApp/myImages/im.gif
is mapped to by the URL
http://machine:port/myApp/myImages/im.gif
• By default, Tomcat maps the root directory
(http://localhost:8090/) to the directory
webapps/ROOT/
- You can change this default
The Directory Structure of a WebThe Directory Structure of a Web
ApplicationApplication
• An application's directory must contain the
following:
- The directory WEB-INF/
- A legal web.xml file under WEB-INF/
<web-app>
</web-app>
From Scratch to ApplicationsFrom Scratch to Applications
Configuring a Web ApplicationConfiguring a Web Application
• Application-specific configuration and declarations are
written in the file myApp/WEB-INF/web.xml
• This file contains:
- Servlet declarations, mappings and parameters
- Default files for directory requests
- Error pages (sent in cases of HTTP errors)
- Security constraints
- Session time-out specification
- Context (application) parameters
- And more…
Error PagesError Pages
• Use the error-page element to define the page
sent in case of an HTTP error that occurs within
the application context
• An error page element has two sub elements:
- error-code - the HTTP error status code
- location - the page that should be sent
Welcome Page ExampleWelcome Page Example
<html>
<head><title>Not Found</title></head>
<body>
<h1 style="text-align:center; color:green">
Sorry, no such file...
</h1>
</body>
</html>
my404.html
<web-app>
<error-page>
<error-code>404</error-code>
<location>/my404.html</location>
</error-page>
</web-app>
web.xml
Welcome PagesWelcome Pages
• The (optional) welcome-file-list element contains a list
of file names
• When the URL request is a directory name, Tomcat
automatically brings the first file on the list
• If that file is not found, the server then tries the next file
in the list, and so on
• This file can be of any type, e.g., HTML, JSP, image,
etc.
• The default welcome list for all applications is set in
$CATALINA_BASE/conf/web.xml
Welcome Page ExampleWelcome Page Example
<html>
<head><title>Welcome</title></head>
<body>
<h1 style="text-align:center; color:red">
Welcome Dear Visitor!
</h1>
</body>
</html>
welcome.html
<web-app>
<welcome-file-list>
<welcome-file>welcome.html</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
web.xml
Tomcat and Java ClassesTomcat and Java Classes
• Tomcat uses Java classes you provide in order to
run Servlets and JSP files
- For example, the Servlets themselves!
• Tomcat 5.x initialization scripts ignore your
environment CLASSPATH variable
• Classes are expected to be placed (or linked) at
some predefined places in its directories
Java Class LocationsJava Class Locations
• Tomcat expects to find Java classes in class files (in a
directory named classes) and JAR files (in a directory
named lib) in the following places:
• TOMCAT-HOME/common/
- Basic runtime classes. No need to touch this directory
• $CATALINA_BASE/shared/
- Classes that are used by all the Web applications
• $CATALINA_BASE/webapps/myApp/WEB-INF/
- Application-specific classes (Servlets are typically here)
Java Class LocationsJava Class Locations
Classes Provided by DBIClasses Provided by DBI
In order to provide the classes you need, like
ORACLE, SAX and DOM-related packages, the
Tomcat-setup script links the directory
$CATALINA_BASE/shared/lib/ to
~dbi/tomcat/shared/lib/, thus the latter
packages are automatically known by your
Tomcat server
Tomcat 5.0 ManagerTomcat 5.0 Manager
• Tomcat 5.0 comes with a Web application called
“manager”, which supports functions for
managing Web applications
• You can either use the HTML interface at
http://<machine>:<port>/manager/html/ or send
direct HTTP requests to it
• You will need to authenticate as a privileged user
- Use the username “admin” with no password
Tomcat 5.0 ManagerTomcat 5.0 Manager
• Using the manager, you can
- Deploy a Web application by posting a WAR file
- Undeploy a deployed Web application
- Start/stop a Web application (make it available/unavailable)
- Reload an existing Web application (unpack new WARs)
• Warning: while “stop” makes an application unavailable,
“undeploy” deletes the application directory and WAR file
from webapps/
Tomcat and EclipseTomcat and Eclipse
• You can use an Eclipse plugin for Tomcat Web-
application development
• The “Sysdeo Eclipse Tomcat Launcher” plugin
is installed in CS
• Using this plugin, you can start/stop the server,
reload an application, etc.
• Detailed explanations in the course home-page
 Tomcat server

More Related Content

What's hot (20)

Java11 New Features
Java11 New FeaturesJava11 New Features
Java11 New Features
 
Apache Server Tutorial
Apache Server TutorialApache Server Tutorial
Apache Server Tutorial
 
Apache web service
Apache web serviceApache web service
Apache web service
 
Core java
Core javaCore java
Core java
 
Apache web server
Apache web serverApache web server
Apache web server
 
Tomcat Server
Tomcat ServerTomcat Server
Tomcat Server
 
Apache web server
Apache web serverApache web server
Apache web server
 
PUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBootPUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBoot
 
An Introduction to Maven
An Introduction to MavenAn Introduction to Maven
An Introduction to Maven
 
Introduction to Web Services
Introduction to Web ServicesIntroduction to Web Services
Introduction to Web Services
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
Servlet.ppt
Servlet.pptServlet.ppt
Servlet.ppt
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Postman.ppt
Postman.pptPostman.ppt
Postman.ppt
 
JNDI
JNDIJNDI
JNDI
 
Nodejs presentation
Nodejs presentationNodejs presentation
Nodejs presentation
 
Introduction to java (revised)
Introduction to java (revised)Introduction to java (revised)
Introduction to java (revised)
 
SOAP--Simple Object Access Protocol
SOAP--Simple Object Access ProtocolSOAP--Simple Object Access Protocol
SOAP--Simple Object Access Protocol
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Introduction to selenium
Introduction to seleniumIntroduction to selenium
Introduction to selenium
 

Viewers also liked

Introduction to Apache Tomcat 7 Presentation
Introduction to Apache Tomcat 7 PresentationIntroduction to Apache Tomcat 7 Presentation
Introduction to Apache Tomcat 7 PresentationTomcat Expert
 
Apache Tomcat 8 Application Server
Apache Tomcat 8 Application ServerApache Tomcat 8 Application Server
Apache Tomcat 8 Application Servermohamedmoharam
 
Internet Information Server (IIS)
Internet Information Server (IIS)Internet Information Server (IIS)
Internet Information Server (IIS)Rosariio92
 
Tomcat and apache httpd training
Tomcat and apache httpd trainingTomcat and apache httpd training
Tomcat and apache httpd trainingFranck SIMON
 
Delivery of media content of IIS Media Services
Delivery of media content of  IIS Media ServicesDelivery of media content of  IIS Media Services
Delivery of media content of IIS Media ServicesSQALab
 
Web весна 2012 лекция 3
Web весна 2012 лекция 3Web весна 2012 лекция 3
Web весна 2012 лекция 3Technopark
 
Java Server Faces + Spring MVC Framework
Java Server Faces + Spring MVC FrameworkJava Server Faces + Spring MVC Framework
Java Server Faces + Spring MVC FrameworkGuo Albert
 
Apache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling UpApache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling UpSander Temme
 
Nashorn: JavaScript Running on Java VM (English)
Nashorn: JavaScript Running on Java VM (English)Nashorn: JavaScript Running on Java VM (English)
Nashorn: JavaScript Running on Java VM (English)Logico
 
Jenkins hudsonci-101002103143-phpapp02
Jenkins hudsonci-101002103143-phpapp02Jenkins hudsonci-101002103143-phpapp02
Jenkins hudsonci-101002103143-phpapp02Praveen Pamula
 
Ajax en Java - GTI780 & MTI780 - ETS - A09
Ajax en Java - GTI780 & MTI780 - ETS - A09Ajax en Java - GTI780 & MTI780 - ETS - A09
Ajax en Java - GTI780 & MTI780 - ETS - A09Claude Coulombe
 
INTRODUCTION TO IIS
INTRODUCTION TO IISINTRODUCTION TO IIS
INTRODUCTION TO IISsanya6900
 
Using Puppet and Cobbler to Automate Your Infrastructure
Using Puppet and Cobbler to Automate Your InfrastructureUsing Puppet and Cobbler to Automate Your Infrastructure
Using Puppet and Cobbler to Automate Your InfrastructurePhil Windley
 
Tomcat Optimisation & Performance Tuning
Tomcat Optimisation & Performance TuningTomcat Optimisation & Performance Tuning
Tomcat Optimisation & Performance Tuninglovingprince58
 
Developing modular, polyglot applications with Spring (SpringOne India 2012)
Developing modular, polyglot applications with Spring (SpringOne India 2012)Developing modular, polyglot applications with Spring (SpringOne India 2012)
Developing modular, polyglot applications with Spring (SpringOne India 2012)Chris Richardson
 
лекция №6
лекция №6лекция №6
лекция №6student_kai
 

Viewers also liked (20)

Introduction to Apache Tomcat 7 Presentation
Introduction to Apache Tomcat 7 PresentationIntroduction to Apache Tomcat 7 Presentation
Introduction to Apache Tomcat 7 Presentation
 
Apache Tomcat 8 Application Server
Apache Tomcat 8 Application ServerApache Tomcat 8 Application Server
Apache Tomcat 8 Application Server
 
Hacking Tomcat
Hacking TomcatHacking Tomcat
Hacking Tomcat
 
Internet Information Server (IIS)
Internet Information Server (IIS)Internet Information Server (IIS)
Internet Information Server (IIS)
 
Understanding IIS
Understanding IISUnderstanding IIS
Understanding IIS
 
Tomcat and apache httpd training
Tomcat and apache httpd trainingTomcat and apache httpd training
Tomcat and apache httpd training
 
Delivery of media content of IIS Media Services
Delivery of media content of  IIS Media ServicesDelivery of media content of  IIS Media Services
Delivery of media content of IIS Media Services
 
Web весна 2012 лекция 3
Web весна 2012 лекция 3Web весна 2012 лекция 3
Web весна 2012 лекция 3
 
Java SE 8 & EE 7 Launch
Java SE 8 & EE 7 LaunchJava SE 8 & EE 7 Launch
Java SE 8 & EE 7 Launch
 
Java Server Faces + Spring MVC Framework
Java Server Faces + Spring MVC FrameworkJava Server Faces + Spring MVC Framework
Java Server Faces + Spring MVC Framework
 
Apache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling UpApache Performance Tuning: Scaling Up
Apache Performance Tuning: Scaling Up
 
Nashorn: JavaScript Running on Java VM (English)
Nashorn: JavaScript Running on Java VM (English)Nashorn: JavaScript Running on Java VM (English)
Nashorn: JavaScript Running on Java VM (English)
 
Jenkins hudsonci-101002103143-phpapp02
Jenkins hudsonci-101002103143-phpapp02Jenkins hudsonci-101002103143-phpapp02
Jenkins hudsonci-101002103143-phpapp02
 
Ajax en Java - GTI780 & MTI780 - ETS - A09
Ajax en Java - GTI780 & MTI780 - ETS - A09Ajax en Java - GTI780 & MTI780 - ETS - A09
Ajax en Java - GTI780 & MTI780 - ETS - A09
 
INTRODUCTION TO IIS
INTRODUCTION TO IISINTRODUCTION TO IIS
INTRODUCTION TO IIS
 
IIS
IISIIS
IIS
 
Using Puppet and Cobbler to Automate Your Infrastructure
Using Puppet and Cobbler to Automate Your InfrastructureUsing Puppet and Cobbler to Automate Your Infrastructure
Using Puppet and Cobbler to Automate Your Infrastructure
 
Tomcat Optimisation & Performance Tuning
Tomcat Optimisation & Performance TuningTomcat Optimisation & Performance Tuning
Tomcat Optimisation & Performance Tuning
 
Developing modular, polyglot applications with Spring (SpringOne India 2012)
Developing modular, polyglot applications with Spring (SpringOne India 2012)Developing modular, polyglot applications with Spring (SpringOne India 2012)
Developing modular, polyglot applications with Spring (SpringOne India 2012)
 
лекция №6
лекция №6лекция №6
лекция №6
 

Similar to Tomcat server

Tomcat Configuration (1)
Tomcat Configuration (1)Tomcat Configuration (1)
Tomcat Configuration (1)nazeer pasha
 
Tomcat configuration
Tomcat configurationTomcat configuration
Tomcat configurationDima Gomaa
 
Web container and Apache Tomcat
Web container and Apache TomcatWeb container and Apache Tomcat
Web container and Apache TomcatAuwal Amshi
 
TOMCAT WEB SERVER TECHNICAL BY SAIKIRAN PANJALA
TOMCAT WEB SERVER TECHNICAL BY SAIKIRAN PANJALATOMCAT WEB SERVER TECHNICAL BY SAIKIRAN PANJALA
TOMCAT WEB SERVER TECHNICAL BY SAIKIRAN PANJALASaikiran Panjala
 
SCWCD : Servlet web applications : CHAP 3
SCWCD : Servlet web applications : CHAP 3SCWCD : Servlet web applications : CHAP 3
SCWCD : Servlet web applications : CHAP 3Ben Abdallah Helmi
 
SCWCD : Servlet web applications : CHAP : 3
SCWCD : Servlet web applications : CHAP : 3SCWCD : Servlet web applications : CHAP : 3
SCWCD : Servlet web applications : CHAP : 3Ben Abdallah Helmi
 
Java Servlets
Java ServletsJava Servlets
Java ServletsNitin Pai
 
Ta Javaserverside Eran Toch
Ta Javaserverside Eran TochTa Javaserverside Eran Toch
Ta Javaserverside Eran TochAdil Jafri
 
Tumbleweed intro
Tumbleweed introTumbleweed intro
Tumbleweed introRich Helton
 
Lecture 19 - Dynamic Web - JAVA - Part 1.ppt
Lecture 19 - Dynamic Web - JAVA - Part 1.pptLecture 19 - Dynamic Web - JAVA - Part 1.ppt
Lecture 19 - Dynamic Web - JAVA - Part 1.pptKalsoomTahir2
 
Lecture 19 dynamic web - java - part 1
Lecture 19   dynamic web - java - part 1Lecture 19   dynamic web - java - part 1
Lecture 19 dynamic web - java - part 1Д. Ганаа
 
New Flash Builder 4 WSDL and HTTP Connectors
New Flash Builder 4 WSDL and HTTP ConnectorsNew Flash Builder 4 WSDL and HTTP Connectors
New Flash Builder 4 WSDL and HTTP Connectorsrtretola
 

Similar to Tomcat server (20)

Tomcat Configuration (1)
Tomcat Configuration (1)Tomcat Configuration (1)
Tomcat Configuration (1)
 
Tomcat configuration
Tomcat configurationTomcat configuration
Tomcat configuration
 
bjhbj
bjhbjbjhbj
bjhbj
 
Web container and Apache Tomcat
Web container and Apache TomcatWeb container and Apache Tomcat
Web container and Apache Tomcat
 
Unit5 servlets
Unit5 servletsUnit5 servlets
Unit5 servlets
 
TOMCAT WEB SERVER TECHNICAL BY SAIKIRAN PANJALA
TOMCAT WEB SERVER TECHNICAL BY SAIKIRAN PANJALATOMCAT WEB SERVER TECHNICAL BY SAIKIRAN PANJALA
TOMCAT WEB SERVER TECHNICAL BY SAIKIRAN PANJALA
 
SCWCD : Servlet web applications : CHAP 3
SCWCD : Servlet web applications : CHAP 3SCWCD : Servlet web applications : CHAP 3
SCWCD : Servlet web applications : CHAP 3
 
Lecture2
Lecture2Lecture2
Lecture2
 
SCWCD : Servlet web applications : CHAP : 3
SCWCD : Servlet web applications : CHAP : 3SCWCD : Servlet web applications : CHAP : 3
SCWCD : Servlet web applications : CHAP : 3
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Cis 274 intro
Cis 274   introCis 274   intro
Cis 274 intro
 
Ta Javaserverside Eran Toch
Ta Javaserverside Eran TochTa Javaserverside Eran Toch
Ta Javaserverside Eran Toch
 
Java Servlets & JSP
Java Servlets & JSPJava Servlets & JSP
Java Servlets & JSP
 
Jira Rev002
Jira Rev002Jira Rev002
Jira Rev002
 
Tumbleweed intro
Tumbleweed introTumbleweed intro
Tumbleweed intro
 
Lecture 19 - Dynamic Web - JAVA - Part 1.ppt
Lecture 19 - Dynamic Web - JAVA - Part 1.pptLecture 19 - Dynamic Web - JAVA - Part 1.ppt
Lecture 19 - Dynamic Web - JAVA - Part 1.ppt
 
Tomcat tutorail
Tomcat tutorailTomcat tutorail
Tomcat tutorail
 
Auxiliary : Tomcat
Auxiliary : TomcatAuxiliary : Tomcat
Auxiliary : Tomcat
 
Lecture 19 dynamic web - java - part 1
Lecture 19   dynamic web - java - part 1Lecture 19   dynamic web - java - part 1
Lecture 19 dynamic web - java - part 1
 
New Flash Builder 4 WSDL and HTTP Connectors
New Flash Builder 4 WSDL and HTTP ConnectorsNew Flash Builder 4 WSDL and HTTP Connectors
New Flash Builder 4 WSDL and HTTP Connectors
 

Recently uploaded

Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAbhinavSharma374939
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 

Recently uploaded (20)

DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog Converter
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 

Tomcat server

  • 1. Apache TomcatApache Tomcat Representation and Management of Data on the Web
  • 2. What is Tomcat?What is Tomcat? • Tomcat is a Servlet container (Web server that interacts with Servlets) developed under the Jakarta Project of Apache Software Foundation • Tomcat implements the Servlet and the Java Server Pages (JSP) specifications of Sun Microsystems • Tomcat is an open-source, non commercial project - Licensed under the Apache Software License • Tomcat is written in Java (OS independent)
  • 3. A Servlet ExampleA Servlet Example public class HelloWorld extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); out.println("<html><head><title>Hello</title></head>"); out.println("<body>"); out.println("<h2>" + new java.util.Date() + "</h2>"); out.println("<h1>Hello World</h1></body></html>"); } } HelloWorld.java http://localhost/dbi/hello
  • 4. A JSP ExampleA JSP Example <html> <head> <title>Hello World</title> </head> <body> <h2><%= new java.util.Date() %></h2> <h1>Hello World</h1> </body> </html> hello.jsp http://localhost/dbi/hello.jsp
  • 5. Another JSP ExampleAnother JSP Example <html> <head><title>Numbers</title></head> <body> <h1>The numbers 1 to 10:</h1> <ul> <% int i; for (i=1; i<=10; ++i) { %> <li>Number <%=i%> </li> <%}%> </ul> </body> </html> numbers.jsp http://localhost/dbi/numbers.jsp
  • 7. Tomcat Directory StructureTomcat Directory Structure
  • 8. Base and Home DirectoriesBase and Home Directories • The directory TOMCAT-HOME contains executables and libraries required for the server launching, running and stopping - This directory is placed under /usr/local/… • The directory TOMCAT-BASE contains the Web-site content, Web applications and configuration data - This directory is placed under your home directory
  • 9. Installing TomcatInstalling Tomcat • Create a directory for tomcat base - For example: mkdir ~/tomcat-base • Set the environment variable CATALINA_BASE to your tomcat-base directory - For example: setenv CATALINA_BASE ~/tomcat-base - Insert this line into your .cshrc file • Run ~dbi/tomcat/bin/setup • $CATALINA_BASE is now a regular Tomcat base directory, and Tomcat is ready to run
  • 10. Running TomcatRunning Tomcat • To start tomcat use ~dbi/tomcat/bin/catalina run • Or, in background, ~dbi/tomcat/bin/catalina start • To stop tomcat use ~dbi/tomcat/bin/catalina stop • To see the default page of Tomcat from your browser use the URL http://<machine-name>:<port>/ - machine-name is the name of the machine on which Tomcat runs and port is the port you chose for Tomcat • You can also use http://localhost:<port>/ if your browser runs on the same machine as Tomcat
  • 11. From Scratch to ServerFrom Scratch to Server
  • 12.
  • 13. Choosing a port for TomcatChoosing a port for Tomcat • In the file $CATALINA_HOME/conf/server.xml you will find the element Connector of Service “Catalina” • Choose a port (greater than 1024) and change the value of the port attribute to your chosen one: <Server> … <Service name="Catalina”> <Connector port="8090"/> … </Service> … </Server>
  • 15. Creating Web ApplicationsCreating Web Applications • A Web application is a self-contained subtree of the Web site • A Web application usually contains several Web resources like HTML files, Servlets, JSP files, and other resources like Database tables • Each Web application has its own subdirectory under the directory $CATALINA_BASE/webapps/
  • 16. The Directory Structure of a WebThe Directory Structure of a Web ApplicationApplication • Tomcat automatically identifies a directory $CATALINA_BASE/webapps/myApp/ with the relative URL /myApp/ • For example, a file named index.html in myApp is mapped to by the following URLs: http://machine:port/myApp/index.html http://machine:port/myApp/
  • 17. The Directory Structure of a WebThe Directory Structure of a Web ApplicationApplication • You can also use subdirectories under myApp • For example: the file myApp/myImages/im.gif is mapped to by the URL http://machine:port/myApp/myImages/im.gif • By default, Tomcat maps the root directory (http://localhost:8090/) to the directory webapps/ROOT/ - You can change this default
  • 18. The Directory Structure of a WebThe Directory Structure of a Web ApplicationApplication • An application's directory must contain the following: - The directory WEB-INF/ - A legal web.xml file under WEB-INF/ <web-app> </web-app>
  • 19. From Scratch to ApplicationsFrom Scratch to Applications
  • 20.
  • 21. Configuring a Web ApplicationConfiguring a Web Application • Application-specific configuration and declarations are written in the file myApp/WEB-INF/web.xml • This file contains: - Servlet declarations, mappings and parameters - Default files for directory requests - Error pages (sent in cases of HTTP errors) - Security constraints - Session time-out specification - Context (application) parameters - And more…
  • 22. Error PagesError Pages • Use the error-page element to define the page sent in case of an HTTP error that occurs within the application context • An error page element has two sub elements: - error-code - the HTTP error status code - location - the page that should be sent
  • 23. Welcome Page ExampleWelcome Page Example <html> <head><title>Not Found</title></head> <body> <h1 style="text-align:center; color:green"> Sorry, no such file... </h1> </body> </html> my404.html <web-app> <error-page> <error-code>404</error-code> <location>/my404.html</location> </error-page> </web-app> web.xml
  • 24.
  • 25.
  • 26. Welcome PagesWelcome Pages • The (optional) welcome-file-list element contains a list of file names • When the URL request is a directory name, Tomcat automatically brings the first file on the list • If that file is not found, the server then tries the next file in the list, and so on • This file can be of any type, e.g., HTML, JSP, image, etc. • The default welcome list for all applications is set in $CATALINA_BASE/conf/web.xml
  • 27. Welcome Page ExampleWelcome Page Example <html> <head><title>Welcome</title></head> <body> <h1 style="text-align:center; color:red"> Welcome Dear Visitor! </h1> </body> </html> welcome.html <web-app> <welcome-file-list> <welcome-file>welcome.html</welcome-file> <welcome-file>index.html</welcome-file> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app> web.xml
  • 28.
  • 29. Tomcat and Java ClassesTomcat and Java Classes • Tomcat uses Java classes you provide in order to run Servlets and JSP files - For example, the Servlets themselves! • Tomcat 5.x initialization scripts ignore your environment CLASSPATH variable • Classes are expected to be placed (or linked) at some predefined places in its directories
  • 30. Java Class LocationsJava Class Locations • Tomcat expects to find Java classes in class files (in a directory named classes) and JAR files (in a directory named lib) in the following places: • TOMCAT-HOME/common/ - Basic runtime classes. No need to touch this directory • $CATALINA_BASE/shared/ - Classes that are used by all the Web applications • $CATALINA_BASE/webapps/myApp/WEB-INF/ - Application-specific classes (Servlets are typically here)
  • 31. Java Class LocationsJava Class Locations
  • 32. Classes Provided by DBIClasses Provided by DBI In order to provide the classes you need, like ORACLE, SAX and DOM-related packages, the Tomcat-setup script links the directory $CATALINA_BASE/shared/lib/ to ~dbi/tomcat/shared/lib/, thus the latter packages are automatically known by your Tomcat server
  • 33. Tomcat 5.0 ManagerTomcat 5.0 Manager • Tomcat 5.0 comes with a Web application called “manager”, which supports functions for managing Web applications • You can either use the HTML interface at http://<machine>:<port>/manager/html/ or send direct HTTP requests to it • You will need to authenticate as a privileged user - Use the username “admin” with no password
  • 34. Tomcat 5.0 ManagerTomcat 5.0 Manager • Using the manager, you can - Deploy a Web application by posting a WAR file - Undeploy a deployed Web application - Start/stop a Web application (make it available/unavailable) - Reload an existing Web application (unpack new WARs) • Warning: while “stop” makes an application unavailable, “undeploy” deletes the application directory and WAR file from webapps/
  • 35. Tomcat and EclipseTomcat and Eclipse • You can use an Eclipse plugin for Tomcat Web- application development • The “Sysdeo Eclipse Tomcat Launcher” plugin is installed in CS • Using this plugin, you can start/stop the server, reload an application, etc. • Detailed explanations in the course home-page