Subscribe to News

How to install Tomcat on windows and deploy a web application on it

Author : Ester Artieda

From TechnologicalWiki

Jump to: navigation, search

+z$8frZdyL%68pSU/:>w<:E3.lG-!XIB

[edit] Install Tomcat on Windows

Install Tomcat is an easy task because we only have to download the installer and follow wizard instructions. We can find binary files on http://tomcat.apache.org/download-60.cgi where we should click over Windows Service Installer.

Once you have download the installer, next step is click over it an follow instructions and select the paths where to install Tomcat and where is our jre.

[edit] Deploy a web app with Tomcat

The first step to delploy a web app is to develop that application. We can find a lot of samples about this topic [1] on the Internet, so we only have to follow this instructions to have a sample of it.

Suposing we have our web app ready, we are going to deploy it. The directory has the following skeleton

Image:webAppDirectory.JPG

where on WEB-INF directory is web app information. We are going to supose our servlet is inside the packet com.mycompany.myproject, in this case we will have to adapt our file directory three to it and the result will be:

/WEB-INF
     |--
     classes
         |--
         com
             |--
             mycompany
                 |--
                 myproject


Next step is to modify the deploy descriptor to register our sampleServlet. This is to say, we have to modify web.xml and introduce servlet parameters:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app PUBLIC
    "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

<web-app>

<servlet>
  <servlet-name>RequestDetails</servlet-name>
  <servlet-class>org.stevengould.javaworld.RequestDetails</servlet-class>
</servlet>

<servlet-mapping>
  <servlet-name>RequestDetails</servlet-name>
  <url-pattern>SampleServlet</url-pattern>
</servlet-mapping>

</web-app>

Now, our web application is ready to be introduced on Tomcat server. So to deploy it we have to copy our WEB-INF directory with all its subdirectories on webapps/ROOT/ Tomcat subdirectory and it will look like:

Image:TomcatDirectories.jpg

Finally we only have to test the servlet writing on our browser http://{address}:{port}/{servletName}.

[edit] References

http://www.idevelopment.info/data/Programming/web/tomcat/Deploy_Web_App_Tomcat_4112.shtml

http://www.java-tips.org/java-tutorials/tutorials/introduction-to-java-servlets-with-netbeans-3.html

http://www.programacion.com/java/articulo/desp_servlets/

Main Collaborators