|
APACHE TOMCAT
6
APACHE TOMCAT 7 JAVASERVER FACES (JSF) JSF 2 PRIMEFACES JSF 1 INTERMEDIATE SERVLETS & JSP JAVA 7 & 8 PROGRAMMING ANDROID PROGRAMMING HADOOP AJAX & GWT JAVASCRIPT & AJAX BASICS PROTOTYPE SCRIPTACULOUS JQUERY DOJO GWT HTML 5 ADVANCED SERVLETS & JSP SPRING HIBERNATE & JPA JAKARTA STRUTS EJB3 WEB SERVICES WITH AXIS2 SCWCD TUTORIALS IN CHINESE TUTORIALS IN JAPANESE
ABOUT THE INSTRUCTOR COURSE REVIEWS JSF 2.0 & PRIMEFACES AJAX (w/ JQUERY, HTML5, ETC.) JAVA 6 & 7 PROGRAMMING ANDROID PROGRAMMING GWT INTERMEDIATE SERVLETS & JSP SPRING FRAMEWORK HIBERNATE & JPA ADVANCED SERVLETS & JSP JAKARTA STRUTS 1.x & STRUTS 2 SCWCD IPHONE PROGRAMMING CUSTOMIZED ON-SITE PUBLIC TRAINING SCHEDULE
|
Configuring & Using Apache TomcatA Tutorial on Installing, Configuring, and Using
|
|||||||||||||||
|
Tomcat 7 with Eclipse (Details here) Recommended for Most Developers |
Tomcat 6 with Eclipse (Details here) Old! Only if Servlet 2.5/2.4 Compatibility Needed |
Manual Tomcat 6 Execution (Details here) Not recommended |
|---|---|---|
|
|
|
Overview
Using Tomcat as a deployment server or integrating Tomcat as a plugin within the regular Apache server or a commercial Web server is more complicated than what is described in this tutorial. Although such integration is valuable for a deployment scenario (see http://tomcat.apache.org/tomcat-7.0-doc/), my goal here is to show how to use Tomcat as a development server on your desktop to use for testing when building applications that use JSF 2, servlets/JSP, or other Java-based dynamic Web technologies. Regardless of what deployment server you use, you'll want a standalone server on your desktop to use for development. By far the best way to use Tomcat for development purposes is from inside Eclipse or another IDE. For that, please see the Eclipse and Tomcat 7 integration tutorial or the Eclipse and Tomcat 6 integration tutorial. For using Tomcat manually (not recommended), see the section below.
The examples here assume you are using Windows, but they can be easily adapted for MacOS, Linux, Solaris, and other versions of Unix. Except when I refer to specific Windows paths (e.g., C:\blah\blah), I use URL-style forward slashes for path separators (e.g., install_dir/webapps/ROOT). Adapt as necessary.
To report errors or omissions in this writeup or to inquire about customized on-site training courses on JSF 2, Ajax, jQuery, Android development, Java 7 or 8 programming, Hadoop, Spring, Hibernate, GWT, HTML5, RESTful Web Services and other Java-related technologies, please contact Marty Hall at hall@coreservlets.com.
If you find these free tutorials helpful, we would appreciate it if you would link to us.
Manual Tomcat 6 Execution: Details
-
Unzip Tomcat.
Unzip tomcat-6.0.28-preconfigured.zip
into the top level of the C drive. This should result in C:\apache-tomcat-6.0.28\.
This preconfigured version of Tomcat has the following settings already in place.
For details on customizing this configuration, please see the detailed
configuration guide.
- The port is changed from 8080 to 80. This
lets you enter URLs of the form http://localhost/... instead of http://localhost:8080/....
- When you download Tomcat from the Apache site, the port is 8080 in case you have another server running on port 80.
- Servlet reloading is enabled. This lets you
deploy a modified servlet .class file without restarting the server.
- When you download Tomcat from the Apache site, servlet reloading is disabled for performance reasons. You might want it disabled on a server used for a deployed application, but you definitely want it enabled during development.
- The invoker servlet is enabled.
This lets you drop a servlet .class file into webapps/appName/WEB-INF/classes/packageName and
immediately run it with a URL of the form http://localhost/appName/servlet/packageName.ServletName.
That is, the invoker servlet saves you from editing web.xml to give a servlet-mapping to your servlet.
- When you download Tomcat from the Apache site, the invoker servlet is disabled. You DEFINITELY want the invoker servlet disabled on a server used for a deployed application, but having it enabled on your development server is very convenient for quick testing.
- Tomcat monitors struts-config.xml and faces-config.xml.
Whenever either of these files changes, Tomcat automatically reloads the Web
application. This saves you from restarting the server when you change these files.
- If you do not use Struts or JSF, this change will not be beneficial to you. But it does not hurt either way.
- Directory listings are turned on.
If you type a URL ending in / and there is no welcome file in that folder, Tomcat shows a directory listing.
- Directory listings were on by default in previous Tomcat versions. They are not required but are convenient during development.
- The port is changed from 8080 to 80. This
lets you enter URLs of the form http://localhost/... instead of http://localhost:8080/....
-
Set
JAVA_HOME. Set this environment variable to point at the top-level of your Java installation directory (e.g., C:\Program Files\Java\jdk1.6.0_21.) Use the Control Panel, see the sample autoexec.bat file, or read this section of the page on configuring your development environment. -
Set
CLASSPATH. Set this environment variable to include ".", C:\Servlets+JSP, and the servlet/JSP JAR files. For details, see the sample autoexec.bat file or this section of the page on configuring your development environment.
For a very quick test, open C:\Servlets+JSP, double click on the shortcut to startup.bat, and open http://localhost/ in your browser. If you see something about Tomcat, the setup was successful. But be sure to do the more complete server tests to verify that you have your development and deployment environment also set up properly.
More Information
|
|
|
Too few developers for
onsite courses? Try
our public courses in MD,
co-sponsored by Johns
Hopkins "Engineering
for Professionals":
JSF2: Modern Web
Apps in Java
(w/ PrimeFaces Intro)
August 12-16 2013
Hadoop: Big-Data
Apps in the Cloud
August 26-30 2013
August 20-22 2013
Java Programming:
A Crash Course
September 9-13 2013
September 16 2013
Spring: Simplifying
Java Applications
October 8-11 2013
RESTful & SOAP
Web Services in Java
October 29-31 2013
Java Persistence with
Hibernate & JPA
November 12-15 2013
Android Programming:
Mobile Apps in Java
December 9-13 2013
Courses at
YOUR Location
• Customized content
• Flexible dates
• Any country


