Skip navigation.
Home

Tomcat Simple Configuration

|>

Since the hardest thing for begginers who wants to work with java web applications is understanding and working with the Tomcat webserver configurations and deployment. I decided to write few tips that helps Tomcat begginers to work and deploy java web applications.

  • Tomcat Directory Structure:
     tomcat/binContains the required startup and shutdown scripts
     tomcat/commonContains classes and library files accessible by all web applications |>serverd by the current tomcat inluding the tomcat server itself
     tomcat/confContains the tomcat configuration files "server.xml" and applications xml configurations under the Catalina dir
     tomcat/logsContains the log files of the tomcat standard output "catalina.out" and the web applications logs usually *.txt
     tomcat/serverContains the server basic classes, libraries, and applications (admin, manager)
     tomcat/sharedContains classes and libraries accessible by all web applications serverd by the tomcat but not accessible to the tomcat itself
     tomcat/tempTemp directory to be used by your application
     tomcat/webappsContains the web applications in a WAR format or in expanded directory structure (illustrated later)
     tomcat/work Contains the compiled JSP files and servlets
    Tomcat Directory Structure
    |>
  • Startup and Shutdown:
    • For startup you will need to run the tomcat/bin/startup.sh script. Usually the tomcat server with the default configurations will run and listen on port 8080 to test it open your browser and type http://localhost:8080/ you should see the tomcat welcome page.
    • For shutdown you will need to run the tomcat/bin/shutdown.sh script. It should take about 5 seconds for the tomcat to shutdown and about 20 to startup.
  • Manager and Admin web applications:
    • The manager should be installed by default. It is used to monitor the status of your web applications serverd by the running tomcat server.
    • To access the manager application you must create a username and password and associate them with the manager role.
    • To create a new user with the manager role got to tomcat/conf/tomcat-users.xml and add the following line   <user username="userName" password="choosePassword" roles="admin,manager"/>    you will need to shutdown and start your tomcat server again in order to apply the changes.
    • Now point with your browser to http://localhost:8080/manager/html it will ask you for a username and password you must provide those with the manager role. You shoud see a list of applications and its status, number of sessions, and a set of commands to use Start |> Stop Reload Undeploy .

      Tomcat Manager Preview

  • Web Application Directory Structure:
    application/
    Where to place your JSPs, images, and files you need web users to access
     application/WEB-INF/Where to place configuration files and files that aren't accessible by the entire web application or browsers
     application/WEB-INF/classes/Where to place your classes and servlets
    application/WEB-INF/lib/
    Jars and external libraries
    />

|>http://michael.foolab.org/tomcat_getting_started