Home > Tomcat > The web application space

The web application space

December 31st, 2008

One of the easy options to start developing in tomcat is to start drooping files in the <Tomcat Home>/webapps/ROOT folder. However, if you are planning to create deployable applications (.war) it is better to create a web application space in to tomcat. The process is not complicated, I found great help reading and following the indication in these web articles: Deploying Web Applications to TomcatDemystifying Tomcat 4’s server.xml FileHow to Create a Web Application in Tomcat Sever? 

In summary what it is necessary to do is the following:

  1. Create a folder for you new application in the <Tomcat Home>/webapps/ folder. Lets call it ‘newapp’.
  2. Inside newapp create the folder ‘WEB-INF’.
  3. Inside WEB-INF create the folders: classes and lib.
  4. Also create a file called ‘web.xml’ and put the following text in it: 
    <?xml version="1.0" encoding="ISO-8859-1"?>
    
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
    
    <web-app>
    </web-app>
  5. Open to edit the file <Tomcat Home>/conf/server.xml and add the node <Context path=”/newapp” docBase=”newapp” debug=”0″ reloadable=”true” /> as a child of  the node <Host> and save it.
  6. For testing purposes create a file in <Tomcat Home>/webapps/newapp called test.jsp with this code in it: 
    <%
    	String message="Hello world!";
    %>
    <%= message %>
  7. Open you favorite internet navigator go to http://localhost:8080/newapp/test.jsp
  8. You have now a new web application space in tomcat.

It is possible to have many web application spaces in tomcat.

    Tomcat

    1. No comments yet.
    1. No trackbacks yet.