SlideShare a Scribd company logo
Tomcat and Servlets 
HaifengLiu
Tutorial Overview 
„Tomcat Overview 
„Setting Up and Running Tomcat on CDF 
„Installing and Running Servletson CDF 
„Setting up SysdeoEclipse Tomcat Launcher plugin 
„FAQ?
Tomcat Overview 
„Tomcatis the servletcontainer 
„History: 
‰ASF: JServ–performance 
‰Sun: ServletEngine --specification 
„Requirements and Quality Goals: 
‰Strict adherence to Sun’s JSP/Servletspecification, Interoperability, Modifiability, Performance, Scalability, High-Availability, Security, … 
---Jakarta Tomcat
Tomcat System
Setting Up Tomcat on CDF 
„Status: Installed with user privileges in 
/u/csc309h/lib/brad/tomcat-5.0.27 
„Step 1 –go to website, read instructions 
http://www.cs.toronto.edu/~delara/courses/csc309/resources/csc309guide.html#WebServer 
„Step 2 –download the tar file tomcat.tar.gz 
„Step 3 –untarit (tar xvztomcat.tar.gz) and copy the files into a working directory which is referedas 
e.g. ~/csc309/ 
„Inside tomcat: 
Bin, conf, logs, webapps, work
Start Tomcat Server 
„Step 1 --cd~/csc309/tomcat/bin 
„Step 2 --Run the script start.sh(may need to chmoda+x*.sh) ./start.sh 
„Step 3 --Enter the port number. Tomcat will use 3 ports, the number entered and the next two (e.g., if you are assigned port 32000, tomcat will use 32000, 32001, 32002). 
„Step 4 –check /bin/ps-ef| grepyour_user_id 
„Step 5 –view http://localhost:your_port_number
Tomcat tutorail
Stop Tomcat Server 
„To stop your server, run bin/stop.sh. 
„Always remember to stop your server before logging off CDF.
Directory Structure 
„Bin –Startup/shutdown scripts and other useful files. 
„Conf –Configuration files, including modules.xml, server.xml, and a number of apps-<name>.xml. 
„Logs –event log file for each day 
„Webapps–web application files 
„Wok --intermediate files (such as compiled JSP files) during its work. If you delete this directory while Tomcat is running you will not be able to execute JSP pages!
Installing and Compiling Servlets 
„Step 1 --Download the sample files, untarit, put into webapps 
„Step 2 --Compile the Java class 
‰Include the following jar file in your CLASSPATH 
/u/csc309h/lib/tomcat-5.0.27/common/lib/servlet-api.jar. 
setenvCLASSPATH ${CLASSPATH}: /u/csc309h/lib/tomcat- 
5.0.27/common/lib/servlet-api.jar 
‰cd~/csc309/tomcat/webapps/csc309/WEB-INF/classes 
‰Compile the servletjavacHelloWorld.java 
„Step 3 --Start Tomcat 
„Step 4 –Start Browser: 
http://127.0.0.1:yourPortNumber/csc309/servlet/HelloWorld
HelloWorldInterface
Adding a Servletto a Web Application 
„Step 1 –Download PrintEnv.javaand copy it to ~/csc309/tomcat/webapps/csc309/WEB-INF/classes 
„Step 2 --Compile PrintEnv.java 
„Step 3 –Add the following entries to the application descriptor located at ~/csc309/tomcat/webapps/csc309/WEB-INF/web.xml. 
<servlet> 
<servlet-name>PrintEnv</servlet-name> 
<servlet-class>PrintEnv</servlet-class> 
</servlet> 
<servlet-mapping> 
<servlet-name>PrintEnv</servlet-name> 
<url-pattern>/servlet/PrintEnv</url-pattern> 
</servlet-mapping> 
„Step 4 --Restart Tomcat 
„Step 5 –Open browser to http://127.0.0.1:yourPortNumber/csc309/servlet/PrintEnv
PrintEnvInterface
SysdeoEclipse Tomcat Launcher plugin 
„Starting, stopping and restarting Tomcat 4.x, 5.0.x, 3.3 
„Registering Tomcat process to Eclipse debugger 
„Creating a WAR project (wizard can update server.xmlfile) 
„Adding Java Projects to Tomcat classpath 
„Setting Tomcat JVM parameters, classpathand bootclasspath 
„Exporting a Tomcat project to a WAR File 
„Choosing Tomcat configuration file 
„Capability to use a special Tomcat classloaderto have classes in several java projects loaded at the same classloaderlevel than classes in a Tomcat project, see readmeDevLoader.html(Thanks Martin Kahr)
Software Prerequisite 
„Tomcat Server – ”http://jakarta.apache.org/tomcat/” 
„Eclipse 3.X – “http://www.eclipse.org/downloads/index.php” 
„SysdeoEclipse tomcat Launcher plugin-- 
”http://www.sysdeo.com/eclipse/tomcatPlugin. 
html”
Setup Tomcat in Eclipse 
„Enable tomcat 
‰Go to the menu "Window-> Preferences" 
‰go to "Tomcat" and select your Tomcat version 
‰adjust the field "Tomcat Home" to point to the install directory 
„Add a new user 
‰scroll down the menu point "Tomcat" and click the item "Tomcat Manager App" 
‰add a username and a password 
‰click on "Add user to tomcat-users.xml" 
„Test Start Tomcat Server
HelloWorldExample 
„Open a new project 
‰select "Tomcat Project"..., click Next button 
‰call our new project "Hello World" 
‰adjust URI http://localhost:8080/HelloWorld/hello 
„create a new class named HelloServletin the directory WEB-INF/src 
„create the file web.xmlin the directory WEB- INF (Note: not in WEB-INF/src!!!) 
„Start browser "http://localhost:8080/HelloWorld/hello"
HelloServlet 
importjava.io.*; 
importjavax.servlet.http.*; 
importjavax.servlet.*; 
publicclass HelloServletextends HttpServlet{ 
publicvoid doGet(HttpServletRequestreq, 
HttpServletResponseres) throws ServletException, 
IOException{ 
PrintWriterout = res.getWriter(); 
out.println("Hello, Brave new World!"); 
out.close(); 
} 
}
Web.xml 
<!DOCTYPE web-app PUBLIC 
'-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN' 
'http://java.sun.com/dtd/web-app_2_3.dtd'> 
<web-app> 
<servlet> 
<servlet-name>hello</servlet-name> 
<servlet-class>HelloServlet</servlet-class> 
</servlet> 
<servlet-mapping> 
<servlet-name>hello</servlet-name> 
<url-pattern>/hello</url-pattern> 
</servlet-mapping> 
</web-app>
Ad

More Related Content

What's hot (20)

Creating your own AtoM demo data set for re-use with Vagrant
Creating your own AtoM demo data set for re-use with VagrantCreating your own AtoM demo data set for re-use with Vagrant
Creating your own AtoM demo data set for re-use with Vagrant
Artefactual Systems - AtoM
 
Auxiliary : Tomcat
Auxiliary : TomcatAuxiliary : Tomcat
Auxiliary : Tomcat
webhostingguy
 
Integration of apache with tomcat
Integration of apache with tomcatIntegration of apache with tomcat
Integration of apache with tomcat
Cognizant
 
Tomcat next
Tomcat nextTomcat next
Tomcat next
Jean-Frederic Clere
 
Integrating open am with liferay portal
Integrating open am with liferay portalIntegrating open am with liferay portal
Integrating open am with liferay portal
prabakaranbrick
 
Apache tomcat
Apache tomcatApache tomcat
Apache tomcat
Abhishek Kesharwani
 
Architecting Large Enterprise Java Projects
Architecting Large Enterprise Java ProjectsArchitecting Large Enterprise Java Projects
Architecting Large Enterprise Java Projects
Markus Eisele
 
Information on Tomcat in cPanel & WHM
Information on Tomcat in cPanel & WHMInformation on Tomcat in cPanel & WHM
Information on Tomcat in cPanel & WHM
HTS Hosting
 
Devopstore
DevopstoreDevopstore
Devopstore
Farkhad Badalov
 
Comprehensive Information on Tomcat
Comprehensive Information on TomcatComprehensive Information on Tomcat
Comprehensive Information on Tomcat
HTS Hosting
 
My SQL 1
My SQL 1My SQL 1
My SQL 1
Mohammad Junaid Khan
 
Glassfish Web Stack Launch Jyri Virkki V2
Glassfish Web Stack Launch Jyri Virkki V2Glassfish Web Stack Launch Jyri Virkki V2
Glassfish Web Stack Launch Jyri Virkki V2
Eduardo Pelegri-Llopart
 
플랫폼 통합을 위한 Client Module 개발 & 배포
플랫폼 통합을 위한 Client Module 개발 & 배포플랫폼 통합을 위한 Client Module 개발 & 배포
플랫폼 통합을 위한 Client Module 개발 & 배포
흥래 김
 
Installation of Dspace in Windows OS: A Complete Documentation
Installation of Dspace in Windows OS: A Complete DocumentationInstallation of Dspace in Windows OS: A Complete Documentation
Installation of Dspace in Windows OS: A Complete Documentation
Ashok Kumar Satapathy
 
JBoss Snowdrop
JBoss SnowdropJBoss Snowdrop
JBoss Snowdrop
Lukas Vlcek
 
How to install laravel framework in windows
How to install laravel framework in windowsHow to install laravel framework in windows
How to install laravel framework in windows
Sabina Sadykova
 
Accessing Oracle 11 g on Mac OS (10.7.5) using Oracle Virtual Box
Accessing Oracle 11 g on Mac OS (10.7.5) using Oracle Virtual Box Accessing Oracle 11 g on Mac OS (10.7.5) using Oracle Virtual Box
Accessing Oracle 11 g on Mac OS (10.7.5) using Oracle Virtual Box
Tejas Pillai
 
Aeon mike guide transparent ssl filtering (1)
Aeon mike guide transparent ssl filtering (1)Aeon mike guide transparent ssl filtering (1)
Aeon mike guide transparent ssl filtering (1)
Conrad Cruz
 
Aeon mike guide transparent ssl filtering
Aeon mike guide transparent ssl filteringAeon mike guide transparent ssl filtering
Aeon mike guide transparent ssl filtering
Conrad Cruz
 
How to install ReactJS software
How to install ReactJS software How to install ReactJS software
How to install ReactJS software
VigneshVijay21
 
Creating your own AtoM demo data set for re-use with Vagrant
Creating your own AtoM demo data set for re-use with VagrantCreating your own AtoM demo data set for re-use with Vagrant
Creating your own AtoM demo data set for re-use with Vagrant
Artefactual Systems - AtoM
 
Integration of apache with tomcat
Integration of apache with tomcatIntegration of apache with tomcat
Integration of apache with tomcat
Cognizant
 
Integrating open am with liferay portal
Integrating open am with liferay portalIntegrating open am with liferay portal
Integrating open am with liferay portal
prabakaranbrick
 
Architecting Large Enterprise Java Projects
Architecting Large Enterprise Java ProjectsArchitecting Large Enterprise Java Projects
Architecting Large Enterprise Java Projects
Markus Eisele
 
Information on Tomcat in cPanel & WHM
Information on Tomcat in cPanel & WHMInformation on Tomcat in cPanel & WHM
Information on Tomcat in cPanel & WHM
HTS Hosting
 
Comprehensive Information on Tomcat
Comprehensive Information on TomcatComprehensive Information on Tomcat
Comprehensive Information on Tomcat
HTS Hosting
 
Glassfish Web Stack Launch Jyri Virkki V2
Glassfish Web Stack Launch Jyri Virkki V2Glassfish Web Stack Launch Jyri Virkki V2
Glassfish Web Stack Launch Jyri Virkki V2
Eduardo Pelegri-Llopart
 
플랫폼 통합을 위한 Client Module 개발 & 배포
플랫폼 통합을 위한 Client Module 개발 & 배포플랫폼 통합을 위한 Client Module 개발 & 배포
플랫폼 통합을 위한 Client Module 개발 & 배포
흥래 김
 
Installation of Dspace in Windows OS: A Complete Documentation
Installation of Dspace in Windows OS: A Complete DocumentationInstallation of Dspace in Windows OS: A Complete Documentation
Installation of Dspace in Windows OS: A Complete Documentation
Ashok Kumar Satapathy
 
How to install laravel framework in windows
How to install laravel framework in windowsHow to install laravel framework in windows
How to install laravel framework in windows
Sabina Sadykova
 
Accessing Oracle 11 g on Mac OS (10.7.5) using Oracle Virtual Box
Accessing Oracle 11 g on Mac OS (10.7.5) using Oracle Virtual Box Accessing Oracle 11 g on Mac OS (10.7.5) using Oracle Virtual Box
Accessing Oracle 11 g on Mac OS (10.7.5) using Oracle Virtual Box
Tejas Pillai
 
Aeon mike guide transparent ssl filtering (1)
Aeon mike guide transparent ssl filtering (1)Aeon mike guide transparent ssl filtering (1)
Aeon mike guide transparent ssl filtering (1)
Conrad Cruz
 
Aeon mike guide transparent ssl filtering
Aeon mike guide transparent ssl filteringAeon mike guide transparent ssl filtering
Aeon mike guide transparent ssl filtering
Conrad Cruz
 
How to install ReactJS software
How to install ReactJS software How to install ReactJS software
How to install ReactJS software
VigneshVijay21
 

Viewers also liked (18)

Java build tool_comparison
Java build tool_comparisonJava build tool_comparison
Java build tool_comparison
Manav Prasad
 
Releasing Projects Using Maven
Releasing Projects Using MavenReleasing Projects Using Maven
Releasing Projects Using Maven
Maria Odea Ching-Mallete
 
Building java projects with maven
Building java projects with mavenBuilding java projects with maven
Building java projects with maven
Juan Carlos Pérez Pardo
 
Java Build Tool course in 2011
Java Build Tool course in 2011Java Build Tool course in 2011
Java Build Tool course in 2011
Ching Yi Chan
 
2 TomcatによるWebアプリケーションサーバ構築 第2章 Tomcat概要(3)-フォルダ構造、マネージャツール
2 TomcatによるWebアプリケーションサーバ構築 第2章 Tomcat概要(3)-フォルダ構造、マネージャツール2 TomcatによるWebアプリケーションサーバ構築 第2章 Tomcat概要(3)-フォルダ構造、マネージャツール
2 TomcatによるWebアプリケーションサーバ構築 第2章 Tomcat概要(3)-フォルダ構造、マネージャツール
Enpel
 
Manen Ant SVN
Manen Ant SVNManen Ant SVN
Manen Ant SVN
Sriskandarajah Suhothayan
 
Java Builds with Maven and Ant
Java Builds with Maven and AntJava Builds with Maven and Ant
Java Builds with Maven and Ant
David Noble
 
Jboss Tutorial Basics
Jboss Tutorial BasicsJboss Tutorial Basics
Jboss Tutorial Basics
Anandraj Kulkarni
 
JEE Programming - 07 EJB Programming
JEE Programming - 07 EJB ProgrammingJEE Programming - 07 EJB Programming
JEE Programming - 07 EJB Programming
Danairat Thanabodithammachari
 
JBoss Application Server 7
JBoss Application Server 7JBoss Application Server 7
JBoss Application Server 7
Ray Ploski
 
WebLogic Deployment Plan Example
WebLogic Deployment Plan ExampleWebLogic Deployment Plan Example
WebLogic Deployment Plan Example
James Bayer
 
Weblogic configuration & administration
Weblogic   configuration & administrationWeblogic   configuration & administration
Weblogic configuration & administration
Muhammad Mansoor
 
Oracle Web Logic server
Oracle Web Logic serverOracle Web Logic server
Oracle Web Logic server
Rakesh Gujjarlapudi
 
Where and when to use the Oracle Service Bus (OSB)
Where and when to use the Oracle Service Bus (OSB)Where and when to use the Oracle Service Bus (OSB)
Where and when to use the Oracle Service Bus (OSB)
Guido Schmutz
 
Oracle SOA Suite 11g Mediator vs. Oracle Service Bus (OSB)
Oracle SOA Suite 11g Mediator vs. Oracle Service Bus (OSB)Oracle SOA Suite 11g Mediator vs. Oracle Service Bus (OSB)
Oracle SOA Suite 11g Mediator vs. Oracle Service Bus (OSB)
Guido Schmutz
 
WebSphere App Server vs JBoss vs WebLogic vs Tomcat (InterConnect 2016)
WebSphere App Server vs JBoss vs WebLogic vs Tomcat (InterConnect 2016)WebSphere App Server vs JBoss vs WebLogic vs Tomcat (InterConnect 2016)
WebSphere App Server vs JBoss vs WebLogic vs Tomcat (InterConnect 2016)
Roman Kharkovski
 
Oracle OSB Tutorial 1
Oracle OSB Tutorial 1Oracle OSB Tutorial 1
Oracle OSB Tutorial 1
Rakesh Gujjarlapudi
 
Oracle WebLogic Server Basic Concepts
Oracle WebLogic Server Basic ConceptsOracle WebLogic Server Basic Concepts
Oracle WebLogic Server Basic Concepts
James Bayer
 
Java build tool_comparison
Java build tool_comparisonJava build tool_comparison
Java build tool_comparison
Manav Prasad
 
Java Build Tool course in 2011
Java Build Tool course in 2011Java Build Tool course in 2011
Java Build Tool course in 2011
Ching Yi Chan
 
2 TomcatによるWebアプリケーションサーバ構築 第2章 Tomcat概要(3)-フォルダ構造、マネージャツール
2 TomcatによるWebアプリケーションサーバ構築 第2章 Tomcat概要(3)-フォルダ構造、マネージャツール2 TomcatによるWebアプリケーションサーバ構築 第2章 Tomcat概要(3)-フォルダ構造、マネージャツール
2 TomcatによるWebアプリケーションサーバ構築 第2章 Tomcat概要(3)-フォルダ構造、マネージャツール
Enpel
 
Java Builds with Maven and Ant
Java Builds with Maven and AntJava Builds with Maven and Ant
Java Builds with Maven and Ant
David Noble
 
JBoss Application Server 7
JBoss Application Server 7JBoss Application Server 7
JBoss Application Server 7
Ray Ploski
 
WebLogic Deployment Plan Example
WebLogic Deployment Plan ExampleWebLogic Deployment Plan Example
WebLogic Deployment Plan Example
James Bayer
 
Weblogic configuration & administration
Weblogic   configuration & administrationWeblogic   configuration & administration
Weblogic configuration & administration
Muhammad Mansoor
 
Where and when to use the Oracle Service Bus (OSB)
Where and when to use the Oracle Service Bus (OSB)Where and when to use the Oracle Service Bus (OSB)
Where and when to use the Oracle Service Bus (OSB)
Guido Schmutz
 
Oracle SOA Suite 11g Mediator vs. Oracle Service Bus (OSB)
Oracle SOA Suite 11g Mediator vs. Oracle Service Bus (OSB)Oracle SOA Suite 11g Mediator vs. Oracle Service Bus (OSB)
Oracle SOA Suite 11g Mediator vs. Oracle Service Bus (OSB)
Guido Schmutz
 
WebSphere App Server vs JBoss vs WebLogic vs Tomcat (InterConnect 2016)
WebSphere App Server vs JBoss vs WebLogic vs Tomcat (InterConnect 2016)WebSphere App Server vs JBoss vs WebLogic vs Tomcat (InterConnect 2016)
WebSphere App Server vs JBoss vs WebLogic vs Tomcat (InterConnect 2016)
Roman Kharkovski
 
Oracle WebLogic Server Basic Concepts
Oracle WebLogic Server Basic ConceptsOracle WebLogic Server Basic Concepts
Oracle WebLogic Server Basic Concepts
James Bayer
 
Ad

Similar to Tomcat tutorail (20)

Apache Tomcat 8 Application Server
Apache Tomcat 8 Application ServerApache Tomcat 8 Application Server
Apache Tomcat 8 Application Server
mohamedmoharam
 
Spring Live Sample Chapter
Spring Live Sample ChapterSpring Live Sample Chapter
Spring Live Sample Chapter
Syed Shahul
 
Mc sl54 051_ (1)
Mc sl54 051_ (1)Mc sl54 051_ (1)
Mc sl54 051_ (1)
AnkitKumar2343
 
Web Applications and Deployment
Web Applications and DeploymentWeb Applications and Deployment
Web Applications and Deployment
BG Java EE Course
 
Introduction to Java Servlets and JSP (1).ppt
Introduction to Java Servlets and JSP (1).pptIntroduction to Java Servlets and JSP (1).ppt
Introduction to Java Servlets and JSP (1).ppt
ansariparveen06
 
Tomcat Configuration (1)
Tomcat Configuration (1)Tomcat Configuration (1)
Tomcat Configuration (1)
nazeer pasha
 
bjhbj
bjhbjbjhbj
bjhbj
MohammedNasser364522
 
Integrating tomcat with apache
Integrating tomcat with apacheIntegrating tomcat with apache
Integrating tomcat with apache
govindraj8787
 
Tomcat server
 Tomcat server Tomcat server
Tomcat server
Utkarsh Agarwal
 
Lect06 tomcat1
Lect06 tomcat1Lect06 tomcat1
Lect06 tomcat1
Phuc Truong Ba
 
Tomcat Server
Tomcat ServerTomcat Server
Tomcat Server
Anirban Majumdar
 
Tomcat + other things
Tomcat + other thingsTomcat + other things
Tomcat + other things
Aravindharamanan S
 
Apache
ApacheApache
Apache
reddivarihareesh
 
Tumbleweed intro
Tumbleweed introTumbleweed intro
Tumbleweed intro
Rich Helton
 
Ta Javaserverside Eran Toch
Ta Javaserverside Eran TochTa Javaserverside Eran Toch
Ta Javaserverside Eran Toch
Adil Jafri
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
Nitin Pai
 
Struts2 tutorial
Struts2 tutorialStruts2 tutorial
Struts2 tutorial
Achyuta Kumar
 
Struts2 tutorial
Struts2 tutorialStruts2 tutorial
Struts2 tutorial
Suhas Kamble
 
Struts2 tutorial
Struts2 tutorialStruts2 tutorial
Struts2 tutorial
izdihara
 
Java Servlets & JSP
Java Servlets & JSPJava Servlets & JSP
Java Servlets & JSP
Manjunatha RK
 
Ad

Recently uploaded (19)

OSI TCP IP Protocol Layers description f
OSI TCP IP Protocol Layers description fOSI TCP IP Protocol Layers description f
OSI TCP IP Protocol Layers description f
cbr49917
 
DNS Resolvers and Nameservers (in New Zealand)
DNS Resolvers and Nameservers (in New Zealand)DNS Resolvers and Nameservers (in New Zealand)
DNS Resolvers and Nameservers (in New Zealand)
APNIC
 
project_based_laaaaaaaaaaearning,kelompok 10.pptx
project_based_laaaaaaaaaaearning,kelompok 10.pptxproject_based_laaaaaaaaaaearning,kelompok 10.pptx
project_based_laaaaaaaaaaearning,kelompok 10.pptx
redzuriel13
 
highend-srxseries-services-gateways-customer-presentation.pptx
highend-srxseries-services-gateways-customer-presentation.pptxhighend-srxseries-services-gateways-customer-presentation.pptx
highend-srxseries-services-gateways-customer-presentation.pptx
elhadjcheikhdiop
 
IT Services Workflow From Request to Resolution
IT Services Workflow From Request to ResolutionIT Services Workflow From Request to Resolution
IT Services Workflow From Request to Resolution
mzmziiskd
 
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHostingTop Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
steve198109
 
Computers Networks Computers Networks Computers Networks
Computers Networks Computers Networks Computers NetworksComputers Networks Computers Networks Computers Networks
Computers Networks Computers Networks Computers Networks
Tito208863
 
APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025
APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025
APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025
APNIC
 
Smart Mobile App Pitch Deck丨AI Travel App Presentation Template
Smart Mobile App Pitch Deck丨AI Travel App Presentation TemplateSmart Mobile App Pitch Deck丨AI Travel App Presentation Template
Smart Mobile App Pitch Deck丨AI Travel App Presentation Template
yojeari421237
 
Mobile database for your company telemarketing or sms marketing campaigns. Fr...
Mobile database for your company telemarketing or sms marketing campaigns. Fr...Mobile database for your company telemarketing or sms marketing campaigns. Fr...
Mobile database for your company telemarketing or sms marketing campaigns. Fr...
DataProvider1
 
Best web hosting Vancouver 2025 for you business
Best web hosting Vancouver 2025 for you businessBest web hosting Vancouver 2025 for you business
Best web hosting Vancouver 2025 for you business
steve198109
 
Understanding the Tor Network and Exploring the Deep Web
Understanding the Tor Network and Exploring the Deep WebUnderstanding the Tor Network and Exploring the Deep Web
Understanding the Tor Network and Exploring the Deep Web
nabilajabin35
 
5-Proses-proses Akuisisi Citra Digital.pptx
5-Proses-proses Akuisisi Citra Digital.pptx5-Proses-proses Akuisisi Citra Digital.pptx
5-Proses-proses Akuisisi Citra Digital.pptx
andani26
 
Determining Glass is mechanical textile
Determining  Glass is mechanical textileDetermining  Glass is mechanical textile
Determining Glass is mechanical textile
Azizul Hakim
 
Reliable Vancouver Web Hosting with Local Servers & 24/7 Support
Reliable Vancouver Web Hosting with Local Servers & 24/7 SupportReliable Vancouver Web Hosting with Local Servers & 24/7 Support
Reliable Vancouver Web Hosting with Local Servers & 24/7 Support
steve198109
 
(Hosting PHising Sites) for Cryptography and network security
(Hosting PHising Sites) for Cryptography and network security(Hosting PHising Sites) for Cryptography and network security
(Hosting PHising Sites) for Cryptography and network security
aluacharya169
 
APNIC Update, presented at NZNOG 2025 by Terry Sweetser
APNIC Update, presented at NZNOG 2025 by Terry SweetserAPNIC Update, presented at NZNOG 2025 by Terry Sweetser
APNIC Update, presented at NZNOG 2025 by Terry Sweetser
APNIC
 
White and Red Clean Car Business Pitch Presentation.pptx
White and Red Clean Car Business Pitch Presentation.pptxWhite and Red Clean Car Business Pitch Presentation.pptx
White and Red Clean Car Business Pitch Presentation.pptx
canumatown
 
Perguntas dos animais - Slides ilustrados de múltipla escolha
Perguntas dos animais - Slides ilustrados de múltipla escolhaPerguntas dos animais - Slides ilustrados de múltipla escolha
Perguntas dos animais - Slides ilustrados de múltipla escolha
socaslev
 
OSI TCP IP Protocol Layers description f
OSI TCP IP Protocol Layers description fOSI TCP IP Protocol Layers description f
OSI TCP IP Protocol Layers description f
cbr49917
 
DNS Resolvers and Nameservers (in New Zealand)
DNS Resolvers and Nameservers (in New Zealand)DNS Resolvers and Nameservers (in New Zealand)
DNS Resolvers and Nameservers (in New Zealand)
APNIC
 
project_based_laaaaaaaaaaearning,kelompok 10.pptx
project_based_laaaaaaaaaaearning,kelompok 10.pptxproject_based_laaaaaaaaaaearning,kelompok 10.pptx
project_based_laaaaaaaaaaearning,kelompok 10.pptx
redzuriel13
 
highend-srxseries-services-gateways-customer-presentation.pptx
highend-srxseries-services-gateways-customer-presentation.pptxhighend-srxseries-services-gateways-customer-presentation.pptx
highend-srxseries-services-gateways-customer-presentation.pptx
elhadjcheikhdiop
 
IT Services Workflow From Request to Resolution
IT Services Workflow From Request to ResolutionIT Services Workflow From Request to Resolution
IT Services Workflow From Request to Resolution
mzmziiskd
 
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHostingTop Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
steve198109
 
Computers Networks Computers Networks Computers Networks
Computers Networks Computers Networks Computers NetworksComputers Networks Computers Networks Computers Networks
Computers Networks Computers Networks Computers Networks
Tito208863
 
APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025
APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025
APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025
APNIC
 
Smart Mobile App Pitch Deck丨AI Travel App Presentation Template
Smart Mobile App Pitch Deck丨AI Travel App Presentation TemplateSmart Mobile App Pitch Deck丨AI Travel App Presentation Template
Smart Mobile App Pitch Deck丨AI Travel App Presentation Template
yojeari421237
 
Mobile database for your company telemarketing or sms marketing campaigns. Fr...
Mobile database for your company telemarketing or sms marketing campaigns. Fr...Mobile database for your company telemarketing or sms marketing campaigns. Fr...
Mobile database for your company telemarketing or sms marketing campaigns. Fr...
DataProvider1
 
Best web hosting Vancouver 2025 for you business
Best web hosting Vancouver 2025 for you businessBest web hosting Vancouver 2025 for you business
Best web hosting Vancouver 2025 for you business
steve198109
 
Understanding the Tor Network and Exploring the Deep Web
Understanding the Tor Network and Exploring the Deep WebUnderstanding the Tor Network and Exploring the Deep Web
Understanding the Tor Network and Exploring the Deep Web
nabilajabin35
 
5-Proses-proses Akuisisi Citra Digital.pptx
5-Proses-proses Akuisisi Citra Digital.pptx5-Proses-proses Akuisisi Citra Digital.pptx
5-Proses-proses Akuisisi Citra Digital.pptx
andani26
 
Determining Glass is mechanical textile
Determining  Glass is mechanical textileDetermining  Glass is mechanical textile
Determining Glass is mechanical textile
Azizul Hakim
 
Reliable Vancouver Web Hosting with Local Servers & 24/7 Support
Reliable Vancouver Web Hosting with Local Servers & 24/7 SupportReliable Vancouver Web Hosting with Local Servers & 24/7 Support
Reliable Vancouver Web Hosting with Local Servers & 24/7 Support
steve198109
 
(Hosting PHising Sites) for Cryptography and network security
(Hosting PHising Sites) for Cryptography and network security(Hosting PHising Sites) for Cryptography and network security
(Hosting PHising Sites) for Cryptography and network security
aluacharya169
 
APNIC Update, presented at NZNOG 2025 by Terry Sweetser
APNIC Update, presented at NZNOG 2025 by Terry SweetserAPNIC Update, presented at NZNOG 2025 by Terry Sweetser
APNIC Update, presented at NZNOG 2025 by Terry Sweetser
APNIC
 
White and Red Clean Car Business Pitch Presentation.pptx
White and Red Clean Car Business Pitch Presentation.pptxWhite and Red Clean Car Business Pitch Presentation.pptx
White and Red Clean Car Business Pitch Presentation.pptx
canumatown
 
Perguntas dos animais - Slides ilustrados de múltipla escolha
Perguntas dos animais - Slides ilustrados de múltipla escolhaPerguntas dos animais - Slides ilustrados de múltipla escolha
Perguntas dos animais - Slides ilustrados de múltipla escolha
socaslev
 

Tomcat tutorail

  • 1. Tomcat and Servlets HaifengLiu
  • 2. Tutorial Overview „Tomcat Overview „Setting Up and Running Tomcat on CDF „Installing and Running Servletson CDF „Setting up SysdeoEclipse Tomcat Launcher plugin „FAQ?
  • 3. Tomcat Overview „Tomcatis the servletcontainer „History: ‰ASF: JServ–performance ‰Sun: ServletEngine --specification „Requirements and Quality Goals: ‰Strict adherence to Sun’s JSP/Servletspecification, Interoperability, Modifiability, Performance, Scalability, High-Availability, Security, … ---Jakarta Tomcat
  • 5. Setting Up Tomcat on CDF „Status: Installed with user privileges in /u/csc309h/lib/brad/tomcat-5.0.27 „Step 1 –go to website, read instructions http://www.cs.toronto.edu/~delara/courses/csc309/resources/csc309guide.html#WebServer „Step 2 –download the tar file tomcat.tar.gz „Step 3 –untarit (tar xvztomcat.tar.gz) and copy the files into a working directory which is referedas e.g. ~/csc309/ „Inside tomcat: Bin, conf, logs, webapps, work
  • 6. Start Tomcat Server „Step 1 --cd~/csc309/tomcat/bin „Step 2 --Run the script start.sh(may need to chmoda+x*.sh) ./start.sh „Step 3 --Enter the port number. Tomcat will use 3 ports, the number entered and the next two (e.g., if you are assigned port 32000, tomcat will use 32000, 32001, 32002). „Step 4 –check /bin/ps-ef| grepyour_user_id „Step 5 –view http://localhost:your_port_number
  • 8. Stop Tomcat Server „To stop your server, run bin/stop.sh. „Always remember to stop your server before logging off CDF.
  • 9. Directory Structure „Bin –Startup/shutdown scripts and other useful files. „Conf –Configuration files, including modules.xml, server.xml, and a number of apps-<name>.xml. „Logs –event log file for each day „Webapps–web application files „Wok --intermediate files (such as compiled JSP files) during its work. If you delete this directory while Tomcat is running you will not be able to execute JSP pages!
  • 10. Installing and Compiling Servlets „Step 1 --Download the sample files, untarit, put into webapps „Step 2 --Compile the Java class ‰Include the following jar file in your CLASSPATH /u/csc309h/lib/tomcat-5.0.27/common/lib/servlet-api.jar. setenvCLASSPATH ${CLASSPATH}: /u/csc309h/lib/tomcat- 5.0.27/common/lib/servlet-api.jar ‰cd~/csc309/tomcat/webapps/csc309/WEB-INF/classes ‰Compile the servletjavacHelloWorld.java „Step 3 --Start Tomcat „Step 4 –Start Browser: http://127.0.0.1:yourPortNumber/csc309/servlet/HelloWorld
  • 12. Adding a Servletto a Web Application „Step 1 –Download PrintEnv.javaand copy it to ~/csc309/tomcat/webapps/csc309/WEB-INF/classes „Step 2 --Compile PrintEnv.java „Step 3 –Add the following entries to the application descriptor located at ~/csc309/tomcat/webapps/csc309/WEB-INF/web.xml. <servlet> <servlet-name>PrintEnv</servlet-name> <servlet-class>PrintEnv</servlet-class> </servlet> <servlet-mapping> <servlet-name>PrintEnv</servlet-name> <url-pattern>/servlet/PrintEnv</url-pattern> </servlet-mapping> „Step 4 --Restart Tomcat „Step 5 –Open browser to http://127.0.0.1:yourPortNumber/csc309/servlet/PrintEnv
  • 14. SysdeoEclipse Tomcat Launcher plugin „Starting, stopping and restarting Tomcat 4.x, 5.0.x, 3.3 „Registering Tomcat process to Eclipse debugger „Creating a WAR project (wizard can update server.xmlfile) „Adding Java Projects to Tomcat classpath „Setting Tomcat JVM parameters, classpathand bootclasspath „Exporting a Tomcat project to a WAR File „Choosing Tomcat configuration file „Capability to use a special Tomcat classloaderto have classes in several java projects loaded at the same classloaderlevel than classes in a Tomcat project, see readmeDevLoader.html(Thanks Martin Kahr)
  • 15. Software Prerequisite „Tomcat Server – ”http://jakarta.apache.org/tomcat/” „Eclipse 3.X – “http://www.eclipse.org/downloads/index.php” „SysdeoEclipse tomcat Launcher plugin-- ”http://www.sysdeo.com/eclipse/tomcatPlugin. html”
  • 16. Setup Tomcat in Eclipse „Enable tomcat ‰Go to the menu "Window-> Preferences" ‰go to "Tomcat" and select your Tomcat version ‰adjust the field "Tomcat Home" to point to the install directory „Add a new user ‰scroll down the menu point "Tomcat" and click the item "Tomcat Manager App" ‰add a username and a password ‰click on "Add user to tomcat-users.xml" „Test Start Tomcat Server
  • 17. HelloWorldExample „Open a new project ‰select "Tomcat Project"..., click Next button ‰call our new project "Hello World" ‰adjust URI http://localhost:8080/HelloWorld/hello „create a new class named HelloServletin the directory WEB-INF/src „create the file web.xmlin the directory WEB- INF (Note: not in WEB-INF/src!!!) „Start browser "http://localhost:8080/HelloWorld/hello"
  • 18. HelloServlet importjava.io.*; importjavax.servlet.http.*; importjavax.servlet.*; publicclass HelloServletextends HttpServlet{ publicvoid doGet(HttpServletRequestreq, HttpServletResponseres) throws ServletException, IOException{ PrintWriterout = res.getWriter(); out.println("Hello, Brave new World!"); out.close(); } }
  • 19. Web.xml <!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN' 'http://java.sun.com/dtd/web-app_2_3.dtd'> <web-app> <servlet> <servlet-name>hello</servlet-name> <servlet-class>HelloServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>hello</servlet-name> <url-pattern>/hello</url-pattern> </servlet-mapping> </web-app>