Contact Us
   
   
 
   
     
 
      
 

Tomcat Installation & Configuration on Windows

AddThis Social Bookmark Button          AddThis Feed Button
Print   Email
 

 

Installation of Tomcat on Windows

 

see more Tomcat Installation on linux

Tomcat is java based web server, support jsp ,servlet, and java application, but does not work as application server. Tomcat need java environment to execute jsp and servlet or java class files. This needs to be JVM installed on server or machine, before running Tomcat.
              Java, JDK, JRE, JVM is available freely from sun, and other third party

 


 

This site provides useful information regarding installation of Tomcat server. The steps by step of the installation are shown properly. Every step will followed by a capture of screen that enable user to better understand what they are doing currently and what they will be doing after. This will attract new user of Tomcat that are using Window platform to further reading on this site before continuing into installation. In the subtitle 'Deployment of jsp or servlet in tomcat', user will be provided with example of creating first servlet. This is helpful for new user to test the example given and get knowledge from that before going in depth.

 

Installation of JDK Java

Download JDK or JRE from sun website
       http://java.sun.com/javase/downloads/index.jsp
 Sun provides different executable file for Windows and Linux operating system version. Sun provide JDK for Linux in .bin or tar.gz format, and for Windows .exe format. After downloading file from sun, install JDK simple double click or through command prompt .

java installation

Default installation directory for java in Windows is Program file Java, and Linux /opt. Tomcat 5.5.17 version requires at least java1.5 version.


tomcat installation process

When jdk is installed in default location, need to configuration the environment variable

Environment Variable Setting

Environment variable is next to set java home in system environment. This will help to know others application where is java is installed and where java file have to compile. JAVA_HOME variable name needs to set in environment variable as variable name and variable value as the java home directory c:\ jdk1.5.0.
Step to do this setting, go to my computer icon and right click and go to properties

Environment variable setting

 

My computer->right click->properties->


tomcat installation

 

Advance tab->environment variables ->

 

system properties with tomcat installation

 

User variables –> New

 

tomcat environment variables

 

Click on new button and new pop up will open.
In variable value, enter your java path where java is installed in system.

Tomcat installation

Tomcat installation is of two types. Apache provides self installer for tomcat installation.This tomcat is in executable binary file. Download,and install, self installer do all work automatically.Second is source code extractor. This tomcat installation is also easy as self installer. Before tomcat installation, check all jvm, java, and environment path set properly.

Apache tomcat is freely available from apache jakarta site
http://archive.apache.org/dist/tomcat/tomcat-5/  
According to per requirement, tomcat is downloaded in form of binaries or source code.
We are using zipped pack for windows installation. Download zipped binaries code latest one from this site.Unzip this code and c:\ drive and anywhere desired directory
After unzipped directory system will like that

 

install tomcat on windows

 

 This is means that tomcat is installed properly and ready to run web server. Open bin directory and double click on startup.bat file. Startup.bat will open in dos command prompt

 

tomcat startup on windows

 

After starting tomcat, check tomcat in web browser by typing localhost:8080 in address bar
    http://localhost:8080/

 

tomcat setup

 

This page shows Tomcat is running properly in your system.

Setting up tomcat port

Apache Tomcat Configuration Tomcat use 8080 port instead of 80 port. User can easily change default port from tomcat. Open c:/tomcat/config/server.xml folder in tomcat installed and open server.xml file.

<!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
    <Connector port="8080" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               connectionTimeout="20000" disableUploadTimeout="true" />
    <!-- Note : To disable connection timeouts, set connectionTimeout value
     to 0 -->

In connector port change 8080 to 80, now save this save and shutdown.bat tomcat and startup.bat tomcat.This time user need not to write 8080 port in http://localhost/

Servlet invoker

Servlet container of tomcat engine doesn’t start automatically. WEB-INF deployment descriptor needs to tell servlet engine, where your servlet and mapping of servlet.This is is can be done without any setting through servlet invoker. We just need to uncommented the code in web.xml in config folder.Servlet invoker automatically load servlet in context and map it.
Open c:/tomcat/config/web.xml and edit this code as shown.
First uncommented invoker then servlet mapping

<!--                                                                      -->
  <!--   debug               Debugging detail level for messages logged     -->
  <!--                       by this servlet.  [0]                          -->

    <servlet>
        <servlet-name>invoker</servlet-name>
        <servlet-class>
          org.apache.catalina.servlets.InvokerServlet
        </servlet-class>
        <init-param>
            <param-name>debug</param-name>
            <param-value>0</param-value>
        </init-param>
        <load-on-startup>2</load-on-startup>
    </servlet>

also uncommented the servlet mapping

<!-- The mapping for the invoker servlet -->
    <servlet-mapping>
        <servlet-name>invoker</servlet-name>
        <url-pattern>/servlet/*</url-pattern>
    </servlet-mapping>

    <!-- The mapping for the JSP servlet -->

If you are using tomcat 6, need to define privileges for context. In tomcat 5.5.x version no need to define privileges for context. Tomcat 5.5.x take automatically.

Privileges setting can be done in tomcat/conf/context.xml file. Add this line

<Context reloadable="true" privileged="true">

Deployment of jsp or servlet in tomcat

All jsp and html page should be kept in C:\tomcat\webapps and create your own folder or keep jsp file under default directory ROOT. We would like to create new folder in webapps as home and keep all files in this folder. In home folder create WEB-INF folder and inside this also create two folder named as classes and lib and keep web.xml in WEB-INF.
                   In classes folder, all servlets and javaBeans should keep,Classes folder generally contains class file and java file and when servlet engine starts, all java and class file loaded in tomcat through bootstrap.jar which is in bin folder. Create a first servlet example see example

Deployment of servlet
Servlet deployment needs to map in deployment descriptor, if you have not enabled servlet invoker. Descriptor give us more feature of deploying servlet with user defined URL context path.

All servlet needs to compile manually and copy to WEB-INF/classes folder.

Descriptor file is web.xml which keeps all information of servlet and taglib’s tld

Suppose we are deploying TestServlet servlet at default package.

WEB-INF/classes/TestServlet.class

Make a file
WEB-INF/web.xml
web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  
  <servlet>
    <servlet-name>TestServlet</servlet-name>
    <servlet-class>TestServlet</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>TestServlet</servlet-name>
    <url-pattern>/servlet/TestServlet</url-pattern>
  </servlet-mapping>

  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

 

Deployment of Application

 

     
  follow EasyWayServer  
     
     
  HTML TagsNew  
     
 
JSP Tutorials New
Learn JSP in very less time with example and output. No more headache to scan books about JSP
 
     
 
JDBC Tutorials New
Learn JDBC in very less time with example.
 
     
 
Tomcat Clustering
Clustering is technique to improve the performance, high scalability, and failover of web-server or any servers. Number of users increase with increase load on the servers
 
     
 
Implementation of tomcat clustering
Simple steps to do tomcat clustering with code
 
     
 
Tomcat Installation & Configuration
Tomcat installation on windows, environment system variables setting in Visual mode for easy installation and configuration of web.xml other servlet invoker setting
 
     
 
Apache Tomcat integration with mod_jk
Integrate Apache web server with tomcat web server with mod_jk
 
     
 
Java Servlet Examples
Learn first servlet by example
 
     
 
Apache installation
Apache installation on windows and linux
 
     
 
Mysql Installation
Mysql installation on windows, Port setting,installing mysql tools query browser, connecting to database,creating database, creating tables
 
     
 
Apache PHP MySql integration
 
 
     
 

Keep up-to-date with all the latest articles, tutorials, reviews by subscribing to our newsletter.

Enter your email address:

 
     
   
 
Link to Us
 
 
If You Like this Article, share this

 
 
     
 
More References
 
Apache Tomcat 5.5 Servlet/JSP Container
 
Tomcat Installation User's Guide
 
Installing Jakarta Tomcat Howto
 
Tomcat Application Developer's Guide
 
tomcat Application installation
 
Jasper 2 JSP Engine How To
 
Virtual Hosting and Tomcat
 
tomcat Overview
 
 
     
 
  Privacy Policy