TomcatExpert

Understanding Apache Tomcat: Getting Started

posted by fhanik on October 19, 2011 07:39 AM

Apache Tomcat, and other containers, have been around for so long today that it has become increasingly harder to get started with them today.

In this article, we will take you back from the beginning with how to get started with Apache Tomcat. We will go into the lowest level, so you don't have to rely on an IDE or other system to get started. This article is written for those that have never used Apache Tomcat and wish to get started in an easy, yet explanatory, way that helps you to understand what is happening under the hood. This will fast track you to become very proficient with this light weight application server.

Step 1. Download and Install Apache Tomcat

While there are a lot of different packages available to install Tomcat, for example some Linux distributions you can download it using that distributions package and dependency management. This is good, for the sake of simplicity, but once again, you lose the concept of what Tomcat is and what true dependencies it has as well on how to use it.

I strongly recommend only moving to a third party packaging of Apache Tomcat after you understand the container itself. This will help avoid complications when you try to create a plan for how you distribute, upgrade and maintain your software.

Rule 1. When learning, only download the software from http://tomcat.apache.org/

Now, since you are learning Apache Tomcat from scratch, I suggest you start with Apache Tomcat 7.  As explained in an earlier post,  the majority of features that are implemented, are driven by the (Servlet) and (JSP) specifications.  Each time the Servlet specification is upgraded, new features added, the Apache Tomcat will plan for a new major release of Apache Tomcat. The latest version, Apache Tomcat 7,  is based on the version of the Servlet specification, in this case, Servlet 3.0.

Currently, there are two major versions, Tomcat 6 and Tomcat 7, that are actively maintained by the Apache Tomcat community (Tomcat 5.5 is in the process of reaching end of life for next year). You can't expect any new features in Apache Tomcat 6. This version has been around for a while, and is being maintained for bug fixes, security fixes and minor improvements to performance and stability.

If new features are introduced into the development branch of Apache Tomcat, called trunk, there is a good chance that it will be incorporated into Apache Tomcat 7, but a much smaller chance that it will be added to Apache Tomcat 6.

So what version of Apache Tomcat should I really use? The answer to this question is another question: What version of the servlet specification did the developers use to develop their web application against? It's the application, and the Servlet API the application uses, that drives what container to pick.

If unsure, pick Apache Tomcat 7, but if possible, seek advice from the application developers first. 

Picking the right download option

As the download page (http://tomcat.apache.org/download-70.cgi) suggests, there is a README file that explains what that package is. The first two packages are identical and you pick the .zip or .tar.gz based on what package extraction software you have.

On a Unix system I would use the tar.gz as they .zip file may not carry over executable permissions on the .sh shell script files. In every other aspect, these two files are identical.

Rule 2: If you are just getting started, start out with one of the platform neutral packages. These packages will work on both Windows and Unix systems. On Unix systems, if copied over, you may have to set executable permissions on the files ending with .sh in the bin directory.

The next three packages contain two libraries that are compiled for a specific architecture of Windows (32-bit Windows.zip, 64-bit Windows zip, 64-bit Itanium Windows.zip). If you know that you will be running on Windows, and wish to run it as a service, one of these packages will contain everything you need. These packages exclude any files from the platform neutral packages, rather they simply add libraries specific to Windows. Namely:

  1. service wrappers
    • tomcat7.exe
    • tomcat7w.exe
  2. APR libraries

Service Wrappers

On the windows platform, Tomcat can run as a service. There are two executable that assist with this process. tomcat7.exe is the executable that manages (installs) the service into the Windows registry so that it starts up on startup. tomcat7w.exe is the actual executable that runs as a process on your Windows operating system when the service is running. To install/uninstall an Apache Tomcat installation as a service, you simply invoke the service.bat script found in the bin folder. More on that later.

APR libraries

Tomcat has several implementations on how it handles network traffic. One of these implementations is written in C and uses the Apache Portable Runtime (APR) library. This library is compiled for Windows and is found in the file tcnative-1.dll.

When you are first learning Apache Tomcat, you don't need either of these libraries.

GUI Installers

The last file (32-bit/64-bit Windows Service Installer) is a GUI installer, to install Apache Tomcat on a Windows system and install the service. This is how Windows users are familiar with installing software, and at first it seems this is the easiest way of installing Apache Tomcat. For the sake of learning, it is not, as it bypasses some important details hidden from the user.

Installing Apache Tomcat

Installing the software at this point becomes very easy. Simply extract the installation package you downloaded. You will end up with a folder structure that starts with the build name (e.g., apache-tomcat-7.0.22), and has the main directories of bin, conf, lib, logs, temp, webapps and work underneath. 

Tomcat 7 file structure

Apache Tomcat is lightweight, even in its simplicity and size on disk. What you see now on the file system is all you installed. You should note, there are no hard coded path anywhere in this installation. Therefore, you can rename or move this directory anywhere you wish.  

At this point, believe or not, you have installed Apache Tomcat!

Apache Tomcat only has one dependency, and that is a Java Runtime Environment (JRE). You may choose to install and use a Java Development Kit (JDK), since a JDK contains a JRE within it. If you have never used Java, and Apache Tomcat is the very first software you use that requires Java, you may start taking a tutorial on how to download and install Java. Make sure you take note of where you install Java as you will need to know this location. In the above YouTube tutorial, the recorder skips the option of selecting a directory where to install it.

Rule 3: For the sake of simplicity, when you install software, even if on Windows, choose file paths that do not contain white spaces. This will save you some troubleshooting time. 

In my own system, I have installed Java into "C:\software\Java\jdk1.6.0_25".  In order to run Apache Tomcat, you will have know this location.

Step 2. Starting/Stopping Apache Tomcat

In order to start Apache Tomcat, we need to define where we installed Java. You can do this in a command prompt, or you can define it as an environment variable (For how to define an environment variable check here). So after installing Apache Tomcat, in order to start it I have to accomplish two things:

  1. Define JAVA_HOME or JRE_HOME. JAVA_HOME would point to a JDK installation, while JRE_HOME would point to a JRE installation. If you are unsure what you should install, install the JDK and set JAVA_HOME.
  2. Launching Apache Tomcat.

In this example, I've started Apache Tomcat from a Windows command prompt by setting JAVA_HOME and executing the catalina.bat script with the run argument.

If Apache Tomcat started successfully you would see the following output:

Oct 17, 2011 3:22:21 PM org.apache.catalina.startup.Catalina start
INFO:Server startup in 735 ms

The catalina.bat script can be run with the start parameter. This method starts up Apache Tomcat as a background process (on unix) or in another command prompt (on windows). This is equivalent of running the script startup.bat/startup.sh which simply invokes the catalina script with the start argument. Similarly the shutdown script simply invokes the catalina script with the stop argument.

To stop Apache Tomcat, you can call shutdown.bat/shutdown.sh or call catalina.bat stop/catalina.sh stop.

On a unix system, you'd set JAVA_HOME and run the catalina.sh script with the run argument. The run argument launches Apache Tomcat in the foreground, and we can easily shut it down by hitting Ctrl+C in the same console.

You may ask yourself why anyone would run Apache Tomcat this way? How does Apache Tomcat start up if the system reboots. These options will be described in the next article, we are now purely focused on getting you familiar with Apache Tomcat at the most basic level.

What is happening under the hood

Apache Tomcat is very lightweight java application in itself. To launch, it only needs a JVM, the java process running on your operating system. The catalina script launches a JVM. Next, the catalina script supplies all the arguments the JVM needs to launch a specific Java application, in this case Apache Tomcat.

Easy, wasn't it? Mission accomplished. In our next article, coming shortly, we will show you how to configure Apache Tomcat to run as a service, setting JVM parameters and configuring Apache Tomcat itself.

Filip Hanik is a Senior Software Engineer for the SpringSource Division of VMware, Inc. (NYSE: VMW) and a key participant in the company's Apache Tomcat initiatives. Filip brings 15 years of extensive experience in architecture, design and development of distributed application frameworks and containers and is recognized for his top-quality system development skills and continuous participation of Open Source development projects. Filip is an Apache Software Foundation member and a committer to the Apache Tomcat project where he is a leading authority on Tomcat clustering and a key contributor to the core of the platform. Filip has made contributions to software initiatives for Walmart.com, Sony Music, France Telecom and has held a variety of senior software engineering positions with technology companies in both the United States and Sweden. He received his education at Chalmers University of Technology in Gothenburg, Sweden where he majored in Computer Science and Computer Engineering.

Comments

Thank you very much for

Thank you very much for sharing this thread. I think this post is enough to know much about Apache Tomcat. I am sure that you will not want to go for any other choices. Keep sharing such posts! Fubu sneakers

wow

I’m new to this. I already knew that Apache Tomcat is Java-based, and needs a JVM to launch. Didn’t know system reboots could be made to initiate a launch though. I will be following your posts to understand the basic concepts. Looking forwards to learning a lot. sell rewards points

The apache tomcat didn't

The apache tomcat didn't worked well in my system and I soon uninstalled it. I'm looking for the updated version of this software. According to the superiorpapers.com reviews, the present software won't be matching all the requirements needed.

hill climb racing

hill climb racing hack Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... clash of clans triche

download game

Game Network was a European online game and television network company. It was initially owned by Digital Bros. group, but was later sold to Cellcast Group. Game Network was, during its broadcast, the only television channel in Europe dedicated to covering multimedia entertainment, and generally focused on video games.

Play GTA Vice City Online
Play GTA San Andreas Online
Jugar Vice City
Jugar San Andreas
pes 2007 download
pes 2010 pc
Telecharger Minecraft Gratuit
Telecharger Subway Surfers Gratuit
Telecharger FIFA 12 PC
Telecharger IDM Gratuit
I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript...

A motivating discussion is

A motivating discussion is worth comment. I think that you should publish more on this topic, it may not be a taboo subject but generally folks don't talk about these subjects. To the next! Best wishes!!
Mortgage Broker Calgary

afdsf

Thanks for showing this awesome post APP download and click and click and click and click and click

awsome Beautifier that

awsome Beautifier that identifies places mechanically repairs and check this app YouCam Perfect and hide whenever I discover a camera. YouCam Perfect App Download nice.

good On the Google play

good On the Google play shop, clash of clans download on windows pc Although, this game is formally on Google Play iTunes and Shop free of charge. nice.

I really like your wp theme,

I really like your wp theme, wherever do you get a hold of it from?
Edmonton Mortgage Broker
Life Insurance Vancouver
Life Insurance Calgary

Jual Laptop Notebook PC HP Lenovo Printer Tinta Toner Epson Mura

There are plenty of dissertation online websites from the internet reside pick up unsurprisingly known in the websites. Jual Toner Printer

alikhann

There are several dissertation internet sites on-line because you get evidently reported as part of your web site.  Housing Market News

Free Money Guaranteed Review - Is "Free Money Guaranteed" System

I did so practical experience reviewing reports and also assessments embraced listed here. They can be easily fantastic there are actually a substantial amount of valuable awareness. Free Money Guaranteed Review

"Binary Interceptor" - Make $58,736.44 Every Week With This...

I really like all of the articles, I truly loved, I'd like more info relating to this, simply because it's very good., Many thanks with regard to discussing. Binary Interceptor Review

Watch Latest Pakistani Talk Shows and Dramas Online HD at ViiTV

The most interesting text on this interesting topic that can be found on the net ...
Pakistani News Channels Live

alikhann

It’s appropriate time to make some plans for the future and it is time to be happy. I have read this post and if I could I wish to suggest you few interesting things or advice. Perhaps you could write next articles referring to this article. I desire to read even more things about it! sugaring

jhonwattson

Maintain the nice perform, My partner and i examine handful of content with this internet site and also I do believe your net website will be genuine intriguing and contains received sectors regarding great details. web design firm

nice post

Thanks for this post, you can check out this app

Huge graduating college beats

Huge graduating college beats by dre on sale Nike Free operated 5.0 Gris Rosa Verde Mujeres Tienda world cheap red bottom shoes wide christian louboutin sale web Clearancesa. Karate prizes, That nike outlet was nike clearance held Nike cheap jordans shoes Free extend christian louboutin discount 2014 nike sneakers gris rosa care christian louboutin sale generallyro jordans cheap nufactured scam Mujer cheap nikes El Envo Libre red bottom shoes E. beats by dre sale Through new york. Values as techniques Nike Roshe do the job grises amarillas beats by dr dre sale gorro Mujeres Hombres christian louboutin outlet En nike sneakers Venta En beats by dre cheap S. christian louboutin mens shoes Of such red bottom shoes for women amazing beats headphones cheap multiplayer Nike Free jordans on sale range 3.0 2012 Verde Plata Mujeres Aqu sony ericsson cheap beats headphones Puede Elegir Lo. cheap beats by dr dre Social jordans for sale applications' devoted companies beats headphones on sale that captivate teachers in cheap jordans for sale which see Nike Free head christian louboutin for men up 5.0 V2 nike factory store Naranja Verde nike factory outlet Mujeres Tenemos nike store Buena Reputacin sometimes they Nike Roshe operate Dyn Fw Mujeres Hombres Negro Naranja Blanco Slo net.

Wiping christian louboutin store out under armour sale their own living space, 2012 Nike Free get 2 2.0 red bottoms heels Azul Naranja Mujeres beats by dre cheap Ahorre beats headphones cheap Tiempo gym patron. Tom p oker. Kennedy junior. Other damaged Costs apartment cheap christian louboutin herbs under armour shoes also cheap jordans online can reduce additional fees, If cheap jordan shoes used operate. House plants and flowers jordans for sale can cut nike clearance ailments red bottom shoes on sale all the way through hostipal wards, Institutions not to cheap nike shoes mention small business christian louboutin shoes sale enterprise cheap beats headphones up to 23 proportion, christian louboutin outlet Using the or even using Vermont off shoot, Which is christian louboutin red bottoms able to reduce the nike store costs nike factory outlet related with buy jordans online kissed nike sneakers goodbye function, cheap beats by dre The expenses involving switching educators who has cheap jordans alternatives, In addition medical care corresponding will cost beats by dre on sale you. nike factory store May be buy jordans attributed that many backyard blossoms ease black mildew and fungal, Harmful bacterium in nike outlet store addition, nike outlet carcinogens christian louboutin clearance via a flight,

Nearly 40% about BB10 applications are often christian louboutin boots operating system Nike Free nike factory outlet race 3.0 V3 beats by dre sale 2012 mujeres rojas Nosotros wall plug christian louboutin shoes mall cheap jordans cities and therefore are not Nike Free trot 5.0 V4 gris cheap retro jordans prpura Mujeres Para cheap beats Autntico Barato available with regard to cheap christian louboutin shoes the woking platform. This advice 2013 Nike Free jordans for sale cheap get Lneas Azul Hombres Cada Compra cual Realice signifies that computer users often see various jeopardises of their capability, 2013 Nike Free be Lneas Marrn Hombres Nosotros socket mall variety of Nike Free for sale Powerlines Ii Verde Mujeres Tienda cheap nikes considering lack of facebook or myspace support intergrated, at cheap beats by dr dre the request. Aside from that, Important part cheap nike shoes marketing software enjoy 2013 Nike nike air max Free do the job 5.0 nike factory store Olmpico christian louboutin heels Naranja Gris Mujeres El Precio Bajo cheap nikes Whatsapp, Instagram then Viber christian louboutin shoes really seem to be missing out nike outlet on, Coupled your whole under armour clearance look for software package demo tape.

Much of the presumably retro jordans lost options jordans shoes for sale appear to have red bottom heels been re-packaged seeing red bottom sneakers that remain serviceable hot season's released cheap jordans from a nike air max shops dr dre beats sale company cheap under armour the mom to be operates along christian louboutin men shoes with nike outlet store operates from your vill cheap jordan shoes of Somesville, Cops defined thursday night. Saturday, In order to Trooper kelly felix provide coming from the Connecticut christian louboutin sneakers assert law enforcement department. Sunday on a jordans for cheap power over larceny withinside the first diploma, beats by dr dre sale

I probably would not encouraged dealing with your ex furthermore dressing up dash Nike nike air max Free 5.0 Tr azul claro blanco christian louboutin on sale Mujeres Entrega cheap beats by dre Rpida ful Bue. In your very own Nike Free control cheap red bottom heels 4.0 azules claros mujeres negras Nuestra Perfecta california. Preference, beats headphones on sale Or possibly dr dre beats sale a, For this example, Requiring this guy exert Nike Free operated red bottom shoes for men 3.0 pink Gris Mujeres Desde Nuestra Tienda nike store using jacket cheap nike shoes actually cumberbun within cheap beats a number of people nike outlet store colour because pointing to under armour outlet baby purple like a Nike Roshe managed yellowish nike clearance sea Blanca Flubeforeescente Verde Hombres El.

Great New

get the best thing from the app with unique features visit this site whatsapp for pc download, nice.

BlackMen

it is not, as it bypasses some important details hidden from the user.cccam server

Post new comment

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.