3.2.3.5  Starting and Stopping Tomcat 
Once you have successfully built the application, you can run it in the servlet engine. The 
command to start Tomcat is simply: 
$ $TOMCAT_HOME/bin/startup.sh
You should receive messages indicating the start up process, similar to this: 
Using classpath:/usr/local/jakarta tomcat 3.2.1/lib/ant.jar:
/usr/local/jakarta tomcat 3.2.1/lib/jasper.jar:
/usr/local/jakarta tomcat 3.2.1/lib/jaxp.jar:
/usr/local/jakarta tomcat 3.2.1/lib/parser.jar:
/usr/local/jakarta tomcat 3.2.1/lib/servlet.jar:
/usr/local/jakarta tomcat 3.2.1/lib/test:
/usr/local/jakarta tomcat3.2.1/lib/webserver.jar:
/usr/java/jdk1.3/lib/tools.jar:
/usr/local/jakarta tomcat 3.2.1/webapps/ROOT/WEB INF/classes:
2001 05 01 12:10:39   ContextManager: Adding context Ctx( /examples )
2001 05 01 12:10:40   ContextManager: Adding context Ctx( /admin )
2001 05 01 12:10:40   ContextManager: Adding context Ctx( /myApp )
cannot load servlet name: controller
2001 05 01
12:10:42
PoolTcpConnector:
Starting
HttpConnectionHandler
on
8080
Tomcat is pre configured to listen and respond to HTTP requests at port 8080. You can verify 
this at the start up, as shown above (last line). There should also be a line indicating that your 
application context was loaded (other bold line). 
Don't worry about the message  cannot load servlet name: controller , which you will probably 
get. This is a servlet defined in the web.xml file, but there is actually no class provided for it in 
our example application; therefore, it cannot be loaded, of course. You can clean up web.xml 
and remove this servlet, as well as any other definitions not required later on. 
Any time that you modify the web.xml file (by adding a new servlet, for example), Tomcat has to 
be restarted so it reloads the Web Application Deployment Descriptor web.xml (However, you 
don't have to restart Tomcat when adding JSP pages or HTML pages, since they do not require 
a modification of web.xml). Before running the start up script again, you have to shut Tomcat 
down properly, or Tomcat will not restart. To do this, use the command: 
$ $TOMCAT_HOME/bin/shutdown.sh
When continuously changing and deploying the application, you may wish to write a batch script 
that stops and restarts Tomcat with a single command.  
42 




Java Web Hosting Application Development Using Java Technologies Hosting




 
TotalRoute.net Business web hosting division of Vision Web Hosting Inc. All rights reserved.