Tomcat Web Container

Tomcat is powerful web container with which you can develop your Servlet & JSP application. Tomcat is designed by Apache to provide support for JSP & Servlet engine. If you know java then you already have the idea of JSP & Servlet. If not then simply remember that Servlet & JSP are used for providing dynamic content to web browser. You can think of JSP as similar to PHP. In this article I’ll explain tomcat in terms of question & answer format.

What is Tomcat?
Simply remember tomcat is free web container that has can be used to run code of JSP & servlets.

What can I do with it?
Tomcat can be used as container that serves your JSP or Servlet application. It can be used as web-server or simply as developer sandbox to test your JSP or Servlet applications before you deploy them. With JSP & Servlet you can design dynamic websites like mentioned below: http://wiki.apache.org/tomcat/PoweredBy

What I need to get started with Tomcat?
Before you install Tomcat on your computer you need to have current version of JDK. You can download the JDK from Sun Microsystems website. If you’re installing Tomcat 6 or later then you should install JDK 5 or 6 higher versions on your computer. After that you can download tomcat from Apache. If you want to use IDE or Text editor that does syntax highlighting for your JSP or java application then you need to download that as well.

So initially basic requirements are:
• Sun Java JDK 5/6
• Tomcat 6.x or Higher
• Eclipse or Netbeans

From where can I download the whole stuff?

Java Development Kit 5/6 can be downloaded from Sun’s website:
http://java.sun.com

Tomcat can be downloaded from this location:
http://tomcat.apache.org/
Note: While installing Tomcat you need to make sure that there are no spaces between the directories, so you can opt for c:\java\tomcat or similar not like program files\tomcat as it contain spaces.

Eclipse for java is available here: http://eclipse.org
Netbeans can ordered as free DVD or download location: http://netbeans.org
How to Set Classpath?
You can set the Environment variable that point to the working directory of tomcat. I’m considering you’re using Tomcat under windows, so to set Environment variable Go to My computer > Properties > Advanced >Environment variables. A new dialog box will appear that in that dialog box click on New Button. And Enter CATALINA_HOME as the variable name and give it the path of your Tomcat installation with ending semicolon. Also Create new variable called %JAVA_HOME% and give it a path of your JDK up to bin directory like C:\jdk6_0_3\bin then end this path with semicolon.

Testing Tomcat
You can test tomcat server using command-line in simple steps. Open the command prompt and navigate to the tomcat installation directory then move to the bin directory. For example, C:\tomcat-6.0\bin\ . Now you can enter the tomcat6.exe and press enter. If server starts properly then there is no problem if it shows JDK related errors then you should check the environment variable for JAVA_HOME variable and CATALINA_HOME variable.

To stop tomcat you’ve to:
(Start>Programs>Apache Tomcat 6>Stop Tomcat)

Tomcat Directory Structure
It is important that you should know what each directory does:
Bin: Bin folder contains shell scripts and batch files that do the job of starting tomcat.
Conf: Conf folder contains Global and server configuration files and other user authentication setting etc.
Logs: Logs folders contain server logs.
Lib: This folder contains the JAR files that are used by Tomcat.
Webapps: This is the place where we store our servlets and JSP application’s directory structure.
Work: Work folder contains files that are meant to be immediate use like pre-compiled files and temporary files etc.

This discussion of directory file is limited as there are other important directories as well. So I’ve covered only those which are important when you’re new to Tomcat. Later you’ll come to know other working directories of tomcat as well.

Where can I get more information and Help?
You can get more information about Tomcat from this website: http://tomcat.apache.org
If you’re looking for Book or FAQ to get your answers about Tomcat then you need to point your browser at: http://tomcatbook.sourceforge.net/

I hope the information above helped. I have laid the information down in terms of FAQ so that most of users get the information as per need, hope it helps this way. If you think I need to include anything extra in this page or if you spotted any error then please don’t hesitate to answer them here.

 

Comments

  1. prashant kumar says:

    Thanks a lotttttttttttt……..
    I am very happy to read about tomcat …thanks again