| 1 | <html><head><META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>Application Developer's Guide - Development Processes</title><meta value="Craig R. McClanahan" name="author"><meta value="craigmcc@apache.org" name="email"></head><body vlink="#525D76" alink="#525D76" link="#525D76" text="#000000" bgcolor="#ffffff"><table cellspacing="0" width="100%" border="0"><!--PAGE HEADER--><tr><td><!--PROJECT LOGO--><a href="http://tomcat.apache.org/"><img border="0" alt=" | 
|---|
| 2 | The Apache Tomcat Servlet/JSP Container | 
|---|
| 3 | " align="right" src="../../images/tomcat.gif"></a></td><td><font face="arial,helvetica,sanserif"><h1>Apache Tomcat 6.0</h1></font></td><td><!--APACHE LOGO--><a href="http://www.apache.org/"><img border="0" alt="Apache Logo" align="right" src="../../images/asf-logo.gif"></a></td></tr></table><table cellspacing="4" width="100%" border="0"><!--HEADER SEPARATOR--><tr><td colspan="2"><hr size="1" noshade></td></tr><tr><!--RIGHT SIDE MAIN BODY--><td align="left" valign="top" width="80%"><table cellspacing="4" width="100%" border="0"><tr><td valign="top" align="left"><h1>Application Developer's Guide</h1><h2>Development Processes</h2></td><td nowrap="true" valign="top" align="right"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table><table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#525D76"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Development Processes"><strong>Development Processes</strong></a></font></td></tr><tr><td><blockquote> | 
|---|
| 4 |  | 
|---|
| 5 | <p>Although application development can take many forms, this manual proposes | 
|---|
| 6 | a fairly generic process for creating web applications using Tomcat.  The | 
|---|
| 7 | following sections highlight the commands and tasks that you, as the developer | 
|---|
| 8 | of the code, will perform.  The same basic approach works when you have | 
|---|
| 9 | multiple programmers involved, as long as you have an appropriate source code | 
|---|
| 10 | control system and internal team rules about who is working on what parts | 
|---|
| 11 | of the application at any given time.</p> | 
|---|
| 12 |  | 
|---|
| 13 | <p>The task descriptions below assume that you will be using CVS for source | 
|---|
| 14 | code control, and that you have already configured access to the appropriate | 
|---|
| 15 | CVS repository.  Instructions for doing this are beyond the scope of this | 
|---|
| 16 | manual.  If you are using a different source code control environment, you | 
|---|
| 17 | will need to figure out the corresponding commands for your system.</p> | 
|---|
| 18 |  | 
|---|
| 19 |  | 
|---|
| 20 | <table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="One-Time Setup of Ant and Tomcat for Development"><strong>One-Time Setup of Ant and Tomcat for Development</strong></a></font></td></tr><tr><td><blockquote> | 
|---|
| 21 |  | 
|---|
| 22 | <p>In order to take advantage of the special Ant tasks that interact with the | 
|---|
| 23 | <em>Manager</em> web application, you need to perform the following tasks | 
|---|
| 24 | once (no matter how many web applications you plan to develop).</p> | 
|---|
| 25 | <ul> | 
|---|
| 26 | <li><em>Configure the Ant custom tasks</em>.  The implementation code for the | 
|---|
| 27 | Ant custom tasks is in a JAR file named | 
|---|
| 28 | <code>$CATALINA_HOME/lib/catalina-ant.jar</code>, which must be | 
|---|
| 29 | copied in to the <code>lib</code> directory of your Ant installation. | 
|---|
| 30 | <br><br></li> | 
|---|
| 31 | <li><em>Define one or more Tomcat users</em>.  The <em>Manager</em> web | 
|---|
| 32 | application runs under a security constraint that requires a user to be | 
|---|
| 33 | logged in, and have the security role <code>manager</code> assigned to | 
|---|
| 34 | him or her.  How such users are defined depends on which Realm you have | 
|---|
| 35 | configured in Tomcat's <code>conf/server.xml</code> file -- see the | 
|---|
| 36 | <a href="../../realm-howto.html">Realm Configuration HOW-TO</a> for more | 
|---|
| 37 | information.  You may define any number of users (with any username | 
|---|
| 38 | and password that you like) with the <code>manager</code> role. | 
|---|
| 39 | <br><br></li> | 
|---|
| 40 | </ul> | 
|---|
| 41 |  | 
|---|
| 42 | </blockquote></td></tr></table> | 
|---|
| 43 |  | 
|---|
| 44 |  | 
|---|
| 45 | <table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Create Project Source Code Directory"><strong>Create Project Source Code Directory</strong></a></font></td></tr><tr><td><blockquote> | 
|---|
| 46 |  | 
|---|
| 47 | <p>The first step is to create a new project source directory, and customize | 
|---|
| 48 | the <code>build.xml</code> and <code>build.properties</code> files you will | 
|---|
| 49 | be using.  The directory structure is described in <a href="source.html">the | 
|---|
| 50 | previous section</a>, or you can use the | 
|---|
| 51 | <a href="../sample/">sample application</a> as a starting point.</p> | 
|---|
| 52 |  | 
|---|
| 53 | <p>Create your project source directory, and define it within your CVS | 
|---|
| 54 | repository.  This might be done by a series of commands like this, where | 
|---|
| 55 | <code>{project}</code> is the name under which your project should be | 
|---|
| 56 | stored in the CVS repository, and {username} is your login username:</p> | 
|---|
| 57 | <div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre> | 
|---|
| 58 | cd {my home directory} | 
|---|
| 59 | mkdir myapp <-- Assumed "project source directory" | 
|---|
| 60 | cd myapp | 
|---|
| 61 | mkdir docs | 
|---|
| 62 | mkdir src | 
|---|
| 63 | mkdir web | 
|---|
| 64 | mkdir web/WEB-INF | 
|---|
| 65 | cvs import -m "Initial Project Creation" {project} \ | 
|---|
| 66 | {username} start | 
|---|
| 67 | </pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table></div> | 
|---|
| 68 |  | 
|---|
| 69 | <p>Now, to verify that it was created correctly in CVS, we will perform a | 
|---|
| 70 | checkout of the new project:</p> | 
|---|
| 71 | <div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre> | 
|---|
| 72 | cd .. | 
|---|
| 73 | mv myapp myapp.bu | 
|---|
| 74 | cvs checkout {project} | 
|---|
| 75 | </pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table></div> | 
|---|
| 76 |  | 
|---|
| 77 | <p>Next, you will need to create and check in an initial version of the | 
|---|
| 78 | <code>build.xml</code> script to be used for development.  For getting | 
|---|
| 79 | started quickly and easily, base your <code>build.xml</code> on the | 
|---|
| 80 | <a href="build.xml.txt">basic build.xml file</a>, included with this manual, | 
|---|
| 81 | or code it from scratch.</p> | 
|---|
| 82 | <div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre> | 
|---|
| 83 | cd {my home directory} | 
|---|
| 84 | cd myapp | 
|---|
| 85 | emacs build.xml   <-- if you want a real editor :-) | 
|---|
| 86 | cvs add build.xml | 
|---|
| 87 | cvs commit | 
|---|
| 88 | </pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table></div> | 
|---|
| 89 |  | 
|---|
| 90 | <p>Until you perform the CVS commit, your changes are local to your own | 
|---|
| 91 | development directory.  Committing makes those changes visible to other | 
|---|
| 92 | developers on your team that are sharing the same CVS repository.</p> | 
|---|
| 93 |  | 
|---|
| 94 | <p>The next step is to customize the Ant <em>properties</em> that are | 
|---|
| 95 | named in the <code>build.xml</code> script.  This is done by creating a | 
|---|
| 96 | file named <code>build.properties</code> in your project's top-level | 
|---|
| 97 | directory.  The supported properties are listed in the comments inside | 
|---|
| 98 | the sample <code>build.xml</code> script.  At a minimum, you will generally | 
|---|
| 99 | need to define the <code>catalina.home</code> property defining where | 
|---|
| 100 | Tomcat 6 is installed, and the manager application username and password. | 
|---|
| 101 | You might end up with something like this:</p> | 
|---|
| 102 | <div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre> | 
|---|
| 103 | # Context path to install this application on | 
|---|
| 104 | app.path=/hello | 
|---|
| 105 |  | 
|---|
| 106 | # Tomcat 6 installation directory | 
|---|
| 107 | catalina.home=/usr/local/apache-tomcat-6.0 | 
|---|
| 108 |  | 
|---|
| 109 | # Manager webapp username and password | 
|---|
| 110 | manager.username=myusername | 
|---|
| 111 | manager.password=mypassword | 
|---|
| 112 | </pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table></div> | 
|---|
| 113 |  | 
|---|
| 114 | <p>In general, you will <strong>not</strong> want to check the | 
|---|
| 115 | <code>build.properties</code> file in to the CVS repository, because it | 
|---|
| 116 | is unique to each developer's environment.</p> | 
|---|
| 117 |  | 
|---|
| 118 | <p>Now, create the initial version of the web application deployment | 
|---|
| 119 | descriptor.  You can base <code>web.xml</code> on the | 
|---|
| 120 | <a href="web.xml.txt">basic web.xml file</a>, or code it from scratch.</p> | 
|---|
| 121 | <div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre> | 
|---|
| 122 | cd {my home directory} | 
|---|
| 123 | cd myapp/web/WEB-INF | 
|---|
| 124 | emacs web.xml | 
|---|
| 125 | cvs add web.xml | 
|---|
| 126 | cvs commit | 
|---|
| 127 | </pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table></div> | 
|---|
| 128 |  | 
|---|
| 129 | Note that this is only an example web.xml file.  The full definition | 
|---|
| 130 | of the deployment descriptor file is in the | 
|---|
| 131 | <a href="http://java.sun.com/products/servlet">Servlet Specification.</a> | 
|---|
| 132 |  | 
|---|
| 133 | </blockquote></td></tr></table> | 
|---|
| 134 |  | 
|---|
| 135 |  | 
|---|
| 136 | <table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Edit Source Code and Pages"><strong>Edit Source Code and Pages</strong></a></font></td></tr><tr><td><blockquote> | 
|---|
| 137 |  | 
|---|
| 138 | <p>The edit/build/test tasks will generally be your most common activities | 
|---|
| 139 | during development and maintenance.  The following general principles apply. | 
|---|
| 140 | As described in <a href="source.html">Source Organization</a>, newly created | 
|---|
| 141 | source files should be located in the appropriate subdirectory, under your | 
|---|
| 142 | project source directory.</p> | 
|---|
| 143 |  | 
|---|
| 144 | <p>Whenever you wish to refresh your development directory to reflect the | 
|---|
| 145 | work performed by other developers, you will ask CVS to do it for you:</p> | 
|---|
| 146 | <div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre> | 
|---|
| 147 | cd {my home directory} | 
|---|
| 148 | cd myapp | 
|---|
| 149 | cvs update -dP | 
|---|
| 150 | </pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table></div> | 
|---|
| 151 |  | 
|---|
| 152 | <p>To create a new file, go to the appropriate directory, create the file, | 
|---|
| 153 | and register it with CVS.  When you are satisfied with it's contents (after | 
|---|
| 154 | building and testing is successful), commit the new file to the repository. | 
|---|
| 155 | For example, to create a new JSP page:</p> | 
|---|
| 156 | <div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre> | 
|---|
| 157 | cd {my home directory} | 
|---|
| 158 | cd myapp/web    <-- Ultimate destination is document root | 
|---|
| 159 | emacs mypage.jsp | 
|---|
| 160 | cvs add mypage.jsp | 
|---|
| 161 | ... build and test the application ... | 
|---|
| 162 | cvs commit | 
|---|
| 163 | </pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table></div> | 
|---|
| 164 |  | 
|---|
| 165 | <p>Java source code that is defined in packages must be organized in a | 
|---|
| 166 | directory hierarchy (under the <strong>src/</strong> subdirectory) that | 
|---|
| 167 | matches the package names.  For example, a Java class named | 
|---|
| 168 | <code>com.mycompany.mypackage.MyClass.java</code> should be stored in file | 
|---|
| 169 | <code>src/com/mycompany/mypackage/MyClass.java</code>. | 
|---|
| 170 | Whenever you create a new subdirectory, don't forget to | 
|---|
| 171 | register it with CVS.</p> | 
|---|
| 172 |  | 
|---|
| 173 | <p>To edit an existing source file, you will generally just start editing | 
|---|
| 174 | and testing, then commit the changed file when everything works.  Although | 
|---|
| 175 | CVS can be configured to required you to "check out" or "lock" a file you | 
|---|
| 176 | are going to be modifying, this is generally not used.</p> | 
|---|
| 177 |  | 
|---|
| 178 | </blockquote></td></tr></table> | 
|---|
| 179 |  | 
|---|
| 180 |  | 
|---|
| 181 | <table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Build the Web Application"><strong>Build the Web Application</strong></a></font></td></tr><tr><td><blockquote> | 
|---|
| 182 |  | 
|---|
| 183 | <p>When you are ready to compile the application, issue the following | 
|---|
| 184 | commands (generally, you will want a shell window open that is set to | 
|---|
| 185 | the project source directory, so that only the last command is needed):</p> | 
|---|
| 186 | <div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre> | 
|---|
| 187 | cd {my home directory} | 
|---|
| 188 | cd myapp    <-- Normally leave a window open here | 
|---|
| 189 | ant | 
|---|
| 190 | </pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table></div> | 
|---|
| 191 |  | 
|---|
| 192 | <p>The Ant tool will be execute the default "compile" target in your | 
|---|
| 193 | <code>build.xml</code> file, which will compile any new or updated Java | 
|---|
| 194 | code.  If this is the first time you compile after a "build clean", | 
|---|
| 195 | it will cause everything to be recompiled.</p> | 
|---|
| 196 |  | 
|---|
| 197 | <p>To force the recompilation of your entire application, do this instead:</p> | 
|---|
| 198 | <div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre> | 
|---|
| 199 | cd {my home directory} | 
|---|
| 200 | cd myapp | 
|---|
| 201 | ant all | 
|---|
| 202 | </pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table></div> | 
|---|
| 203 |  | 
|---|
| 204 | <p>This is a very good habit immediately before checking in changes, to | 
|---|
| 205 | make sure that you have not introduced any subtle problems that Javac's | 
|---|
| 206 | conditional checking did not catch.</p> | 
|---|
| 207 |  | 
|---|
| 208 | </blockquote></td></tr></table> | 
|---|
| 209 |  | 
|---|
| 210 |  | 
|---|
| 211 | <table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Test Your Web Application"><strong>Test Your Web Application</strong></a></font></td></tr><tr><td><blockquote> | 
|---|
| 212 |  | 
|---|
| 213 | <p>To test your application, you will want to install it under Tomcat.  The | 
|---|
| 214 | quickest way to do that is to use the custom Ant tasks that are included in | 
|---|
| 215 | the sample <code>build.xml</code> script.  Using these commands might follow | 
|---|
| 216 | a pattern like this:</p> | 
|---|
| 217 | <ul> | 
|---|
| 218 | <li><em>Start Tomcat 6 if needed</em>.  If Tomcat 6 is not already running, | 
|---|
| 219 | you will need to start it in the usual way. | 
|---|
| 220 | <br><br></li> | 
|---|
| 221 | <li><em>Compile your application</em>.  Use the <code>ant compile</code> | 
|---|
| 222 | command (or just <code>ant</code>, since this is the default).  Make | 
|---|
| 223 | sure that there are no compilation errors. | 
|---|
| 224 | <br><br></li> | 
|---|
| 225 | <li><em>Install the application</em>.  Use the <code>ant install</code> | 
|---|
| 226 | command.  This tells Tomcat to immediately start running your app on | 
|---|
| 227 | the context path defined in the <code>app.path</code> build property. | 
|---|
| 228 | Tomcat does <strong>NOT</strong> have to be restarted for this to | 
|---|
| 229 | take effect.<br><br></li> | 
|---|
| 230 | <li><em>Test the application</em>.  Using your browser or other testing | 
|---|
| 231 | tools, test the functionality of your application. | 
|---|
| 232 | <br><br></li> | 
|---|
| 233 | <li><em>Modify and rebuild as needed</em>.  As you discover that changes | 
|---|
| 234 | are required, make those changes in the original <strong>source</strong> | 
|---|
| 235 | files, not in the output build directory, and re-issue the | 
|---|
| 236 | <code>ant compile</code> command.  This ensures that your changes will | 
|---|
| 237 | be available to be saved (via <code>cvs commit</code>) later on -- | 
|---|
| 238 | the output build directory is deleted and recreated as necessary. | 
|---|
| 239 | <br><br></li> | 
|---|
| 240 | <li><em>Reload the application</em>.  Tomcat will recognize changes in | 
|---|
| 241 | JSP pages automatically, but it will continue to use the old versions | 
|---|
| 242 | of any servlet or JavaBean classes until the application is reloaded. | 
|---|
| 243 | You can trigger this by executing the <code>ant reload</code> command. | 
|---|
| 244 | <br><br></li> | 
|---|
| 245 | <li><em>Remove the application when you re done</em>.  When you are through | 
|---|
| 246 | working on this application, you can remove it from live execution by | 
|---|
| 247 | running the <code>ant remove</code> command.</li> | 
|---|
| 248 | </ul> | 
|---|
| 249 |  | 
|---|
| 250 | <p>Do not forget to commit your changes to the source code repository when | 
|---|
| 251 | you have completed your testing!</p> | 
|---|
| 252 |  | 
|---|
| 253 | </blockquote></td></tr></table> | 
|---|
| 254 |  | 
|---|
| 255 |  | 
|---|
| 256 | <table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Creating a Release"><strong>Creating a Release</strong></a></font></td></tr><tr><td><blockquote> | 
|---|
| 257 |  | 
|---|
| 258 | <p>When you are through adding new functionality, and you've tested everything | 
|---|
| 259 | (you DO test, don't you :-), it is time to create the distributable version | 
|---|
| 260 | of your web application that can be deployed on the production server.  The | 
|---|
| 261 | following general steps are required:</p> | 
|---|
| 262 | <ul> | 
|---|
| 263 | <li>Issue the command <code>ant all</code> from the project source | 
|---|
| 264 | directory, to rebuild everything from scratch one last time. | 
|---|
| 265 | <br><br></li> | 
|---|
| 266 | <li>Use the <code>cvs tag</code> command to create an identifier for | 
|---|
| 267 | all of the source files utilized to create this release.  This allows | 
|---|
| 268 | you to reliably reconstruct a release (from sources) at a later | 
|---|
| 269 | time.</li> | 
|---|
| 270 | <li>Issue the command <code>ant dist</code> to create a distributable | 
|---|
| 271 | web application archive (WAR) file, as well as a JAR file containing | 
|---|
| 272 | the corresponding source code. | 
|---|
| 273 | <br><br></li> | 
|---|
| 274 | <li>Package the contents of the <code>dist</code> directory using the | 
|---|
| 275 | <strong>tar</strong> or <strong>zip</strong> utility, according to | 
|---|
| 276 | the standard release procedures used by your organization.</li> | 
|---|
| 277 | </ul> | 
|---|
| 278 |  | 
|---|
| 279 | </blockquote></td></tr></table> | 
|---|
| 280 |  | 
|---|
| 281 |  | 
|---|
| 282 | </blockquote></td></tr></table></td></tr><!--FOOTER SEPARATOR--><tr><td colspan="2"><hr size="1" noshade></td></tr><!--PAGE FOOTER--><tr><td colspan="2"><div align="center"><font size="-1" color="#525D76"><em> | 
|---|
| 283 | Copyright © 1999-2008, Apache Software Foundation | 
|---|
| 284 | </em></font></div></td></tr></table></body></html> | 
|---|