* DISCLAIMER - This simple How-To shows you one of many ways to setup a working project using
the Struts framework. This is mainly geared toward struts users who are new to Eclipse, and
don't want to spend a lot of time figuring out the differences between their old IDE (if any)
and this one.
I will also apologize ahead of time for the formatting of this page.
In this How-To, I will demonstrate (using Eclipse 2.0.1) how to setup, compile, run,
and debug the struts-example web application that is bundled with the distribution.
Next, I will modify the code to pull some data from a MySql database using the popular
relational mapping tool OJB. (This is actually quite simple)
Before we begin, you will need to create a directory somewhere to store your project.
I typically use C:\personal\development\Projects\(some project)
Once that's done, extract the struts-example.war to that directory
(using your favorite zip utility)
Delete the META-INF folder because this will be created during the build/jar/war process.
Add a build.
XML file to the project root. I use something like this:
<project name="Struts Example" default="main" basedir="."><!--This is a basic build script, only the minimums here --><!-- Tell ant to use my environment variables --> <property environment="env"/><property file="./build.properties"/><property name="build.compiler"value="modern"/><property name="build.dir" value="./WEB-INF/classes" /><property name="src.dir"value="./WEB-INF/src"/> <property name="servlet.jar"value="/Apache_Home/jakarta-servletapi-4/lib/servlet.jar"/><property name="war.file"value="struts-example"/><property name="war.file.name"value="${war.file}.war"/><property name="tomcat.home" value="${env.CATALINA_HOME}"/><property name="deploy.dir"value="${tomcat.home}/webapps"/><path id="project.class.path"><fileset dir="./WEB-INF/lib/"><include name="**/*.jar"/></fileset><pathelement path="${src.dir}"/><pathelement path="${servlet.jar}"/> </path><target name="clean"> <delete dir="${build.dir}" includeEmptyDirs="true" /></target> <target name="prep"> <mkdir dir="${build.dir}"/></target><target name="compile"><JavaCSrcdir="${src.dir}"destdir="${build.dir}"debug="on" deprecation="on"> <include name="**/*.Java"/> <classpath refid="project.class.path"/></Javac></target><target name="cleanWebApp"><delete file="${deploy.dir}/${war.file.name}" /> <deletedir="${deploy.dir}/${war.file}" includeEmptyDirs="true" /></target><target name="war"> <war warfile="${war.file.name}" webXML="./WEB-INF/web.XML"><fileset dir="./" includes="**/*.*" excludes="*.war, **/*.NBAttrs, web.XML, **/WEB-INF/**/*.*, **/project-files/**/*.*"/><webinfdir="./WEB-INF" includes="**/*" excludes="web.XML, **/*.jar, **/*.class"/><libdir="./WEB-INF/lib"/><classes dir="${build.dir}" includes="**/*.properties" /> </war></target><target name="deploy"> <copy todir="${deploy.dir}"><fileset dir="./" includes="${war.file.name}"/> </copy></target><target name="main" depends="clean, prep, cleanWebApp, compile, war"/> </project> - Create a new project.