Section 4.4. Building the Application


4.4. Building the Application

Now that we have reviewed the code, let's build it and try it out. It's very similar to the example in the previous chapter, and because I don't like to overwrite my work, I put the new application in its own directory tree. The directory structure I used is shown in Figure 4-2.

Figure 4-2. Directory structure for Ajax Character Decoder (second version)


This is just a guide so you can see how I built the sample. You can name your directories differently as long as you know how to configure the application server properly.

The web.xml file for the project is presented in Example 4-8.

Example 4-8. web.xml

 <!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>AjaxResponseServlet</servlet-name>         <servlet-class>             com.AJAXbook.servlet.AjaxResponseServlet         </servlet-class>         <load-on-startup>1</load-on-startup>     </servlet>     <servlet-mapping>         <servlet-name>AjaxResponseServlet</servlet-name>         <url-pattern>/response</url-pattern>     </servlet-mapping>     <welcome-file-list>         <welcome-file>index.jsp</welcome-file>     </welcome-file-list> </web-app> 

The build.xml file for the project is shown in Example 4-9.

Example 4-9. build.xml

 <?xml version="1.0"?> <project name="AJAX-CODECONVERTER " default="compile" basedir=".">     <property environment="env"/>     <property name="src.dir" value="src"/>     <property name="test.dir" value="test"/>     <property name="war.dir" value="war"/>     <property name="db.dir" value="db"/>     <property name="class.dir" value="${war.dir}/WEB-INF/classes"/>     <property name="test.class.dir" value="${test.dir}/classes"/>     <property name="lib.dir" value="${war.dir}/WEB-INF/lib"/>     <property name="webapp.dir"               value="${env.TOMCAT_HOME}/webapps/ajaxcodeconverter-lab2"/>     <path >         <fileset dir="${lib.dir}">             <include name="*.jar"/>         </fileset>     </path>     <target name="testenv">         <echo message="env.TomcatHome=${env.TOMCAT_HOME}"/>         <echo message="env.ANT_HOME=${env.ANT_HOME}"/>     </target>     <target name="init">         <mkdir dir="${class.dir}"/>         <mkdir dir="${test.class.dir}"/>     </target>     <target name="compile" depends="init"             description="Compiles all source code.">         <javac srcdir="${src.dir}" destdir="${class.dir}" debug="on"                classpathref="ajax.class.path"/>     </target>     <target name="clean" description="Erases contents of classes dir">         <delete dir="${class.dir}"/>         <delete dir="${test.class.dir}"/>     </target>     <target name="deploy" depends="compile"             description="Copies the contents of web-app to destination dir">         <copy todir="${webapp.dir}">             <fileset dir="${war.dir}"/>         </copy>     </target> </project> 




Ajax on Java
Ajax on Java
ISBN: 0596101872
EAN: 2147483647
Year: 2007
Pages: 78

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net