tomcat celsina bignoli [email protected]. history of tomcat tomcat is the result of the integration...

13
Tomcat Celsina Bignoli [email protected]

Upload: benjamin-gardner

Post on 23-Dec-2015

213 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Tomcat Celsina Bignoli bignolic@smccd.net. History of Tomcat Tomcat is the result of the integration of two groups of developers. – JServ, an open source

Tomcat

Celsina [email protected]

Page 2: Tomcat Celsina Bignoli bignolic@smccd.net. History of Tomcat Tomcat is the result of the integration of two groups of developers. – JServ, an open source

History of Tomcat

• Tomcat is the result of the integration of two groups of developers.– JServ, an open source implementation of the Servlet

specification. – Sun’s own servlet engine.

• The focus of the two groups was different:– JServ concentrated on performance– Sun’s implementation was more concerned with adherence to

specification.

• Sun donated the code to Apache Software Foundation. A group was formed – named Jakarta - that was given a charter of merging the implementations

• Tomcat was born

Page 3: Tomcat Celsina Bignoli bignolic@smccd.net. History of Tomcat Tomcat is the result of the integration of two groups of developers. – JServ, an open source

Tomcat Requirements

• Strict adherence to Sun’s JSP/Servlet specification

• Interoperability • Modifiability • Performance • Scalability • High-availability • Security

Page 4: Tomcat Celsina Bignoli bignolic@smccd.net. History of Tomcat Tomcat is the result of the integration of two groups of developers. – JServ, an open source

Architecture

Page 5: Tomcat Celsina Bignoli bignolic@smccd.net. History of Tomcat Tomcat is the result of the integration of two groups of developers. – JServ, an open source

Architecture• Server: Server represents the entire Tomcat server. One server per

JVM. • Service: Service component creates the connectors and associates

the engine with this group of connectors. • Connector: Connectors are components that implement the socket

listeners. They connect web applications to clients. This component provides flexibility to the Tomcat architecture. It allows the Tomcat servlet engine to integrate with many different types of web servers such as Apache, IIS etc.

• Engine: Engine is the top level container. It examines the request and routes the request to the appropriate virtual host.

• Host: This allows multiple servers to be configured on the same physical machine and be identified by separate IP addresses.

• Context: This represents a single web application

Page 6: Tomcat Celsina Bignoli bignolic@smccd.net. History of Tomcat Tomcat is the result of the integration of two groups of developers. – JServ, an open source

Tomcat Installation and Configuration

• Install JDK1.5

• Download the Jakarta Tomcat software

• Set the JAVA_HOME variable

• Change port from 8080 to 80 (optional)

• Set the CATALINA_HOME variable

Page 7: Tomcat Celsina Bignoli bignolic@smccd.net. History of Tomcat Tomcat is the result of the integration of two groups of developers. – JServ, an open source

Changing port to 80

• configure Tomcat to run on the default HTTP port (80) instead of the out-of-the-box port of 8080.

• Making this change lets you use URLs of the form http://localhost/blah instead of http://localhost:8080/blah

• Some versions of Windows XP automatically start IIS on port 80. – So, if you use XP you may need to disable IIS (see the

Administrative Tools section of the Control Panel). • To change the port, edit install_dir/conf/server.xml and

change the port attribute of the Connector element from 8080 to 80<Connector port="80" ... maxThreads="150" minSpareThreads="25" ...

Page 8: Tomcat Celsina Bignoli bignolic@smccd.net. History of Tomcat Tomcat is the result of the integration of two groups of developers. – JServ, an open source

Setting CATALINA_HOME Variable

• set the CATALINA_HOME environment variable to refer to the top-level directory of the Apache Tomcat installation (e.g., C:\jakarta-tomcat-5.5.15).

• This variable identifies the Tomcat installation directory to the server.

Page 9: Tomcat Celsina Bignoli bignolic@smccd.net. History of Tomcat Tomcat is the result of the integration of two groups of developers. – JServ, an open source

Testing the Server

• Involves two steps: – Verifying that the server can even start – Checking that you can access your own

HTML and JSP pages

• use the default Web application. – put HTML and JSP pages in install_dir/webapps/ROOT or install_dir/webapps/ROOT/somePath and access them with http://localhost/filename or http://localhost/somePath/filename.

Page 10: Tomcat Celsina Bignoli bignolic@smccd.net. History of Tomcat Tomcat is the result of the integration of two groups of developers. – JServ, an open source

Setting the Development Environment

• Define a working directory in which to place the servlets and JSP pages that you develop

• The development directory should NOT reside in the Tomcat deployment directory

Page 11: Tomcat Celsina Bignoli bignolic@smccd.net. History of Tomcat Tomcat is the result of the integration of two groups of developers. – JServ, an open source

Making Shortcuts to Start and Stop the Server

• place shortcuts to the server startup and shutdown scripts inside the main development directory or on the desktop.– Go to install_dir/bin, right-click on startup.bat,

and select Copy. – go to your development directory, right-click in

the window, and select Paste Shortcut (not just Paste).

– Repeat the process for install_dir/bin/shutdown.bat.

Page 12: Tomcat Celsina Bignoli bignolic@smccd.net. History of Tomcat Tomcat is the result of the integration of two groups of developers. – JServ, an open source

Setting CLASSPATH

• Since servlets and JSP are not part of the Java 2 platform, standard edition, you have to identify the servlet classes to the compiler.

• The server already knows about the servlet classes, but the compiler (i.e., javac) you use for development probably doesn't.

• Include the following jar file in the CLASSPATH– install_dir/common/lib/servlet-api.jar – install_dir/common/lib/jsp-api.jar – Alternatively you can put the above jar files in

java_dir/lib/ext

Page 13: Tomcat Celsina Bignoli bignolic@smccd.net. History of Tomcat Tomcat is the result of the integration of two groups of developers. – JServ, an open source

Compiling and Testing Simple Servlets

• to verify the environment is all set compile and run some simple Servlet, i.e. HelloServlet.java

• the location for servlets in the default Web application is:install_dir/webapps/ROOT/WEB-INF/classes

• Once you compile HelloServlet.java, put HelloServlet.class in:install_dir/webapps/ROOT/WEB-INF/classes

• After compiling the code, access the servlet with the URL:http://localhost/servlet/HelloServlet