blob: d3d8eca27b17aa13c24e15bea5bf79ce23cb6f4f [file] [log] [blame]
<document>
<title>User Guide - Quick Start</title>
<toc name="toc-user-guide" chapter="3. Quick Start"/>
<body>
<section name="3. Quick Start">
<subsection name="3.3 JSP/Struts Tutorial">
<p>This is a simple Cayenne web application tutorial. Full
tutorial source code is included in Cayenne distribution in
"src/tutorials" folder. </p>
<subsection name="3.3.1 Prepare the Environment">
<p>Make sure you successfully finished <a
href="index.html">common setup steps</a>.</p>
<p>Install a web container. This tutorial was tested with
<a href=
"http://jakarta.apache.org/tomcat/index.html">Tomcat</a>.
It should work with any other container that is
compliant with Servlet 2.3 specification. All
references to Tomcat below should apply in some form to
other web containers as well.</p>
<p>Use tutorial source directory distributed with Cayenne
at
<code>$CAYENNE_HOME/src/tutorials/cayenne-web-app</code>
as a project directory.</p>
<p>Copy <code>cayenne.jar</code> to the
<code>WEB-INF/lib</code> subdirectory of the tutorial
project directory.</p>
<p>Copy JDBC driver jar file to <code>WEB-INF/lib</code>
subdirectory of the tutorial project. </p>
<p>Install Struts (Tutorial was testsed with Struts 1.1,
other versions of Struts may require a different
setup):</p>
<ul>
<li>Download Struts from <a href=
"http://jakarta.apache.org/struts/index.html">Jakarta
Struts site</a>, unpack it to any convenient
directory.</li>
<li>Copy all JAR files distributed with Struts (located
in <code>lib</code> subdirectory) to
<code>WEB-INF/lib</code> subdirectory of the
tutorial project.</li>
<li>Copy all the *.tld files and validator-rules.xml
from Struts <code>lib</code> subdirectory to
<code>WEB-INF</code> subdirectory of the tutorial
project. </li>
</ul>
<br/>
</subsection>
<subsection name="3.3.2 Prepare Tutorial Database">
<p>Run <a
href="../../tutorials/cayenne-web-app/tutorialdb.sql"><code>tutorialdb.sql</code></a>
script located in the project directory to create test
tables. See step 3.2.2 from Command Line Tutorial.</p>
</subsection>
<subsection name="3.3.3 Setup DataNode">
<p>See step 3.2.3 from Command Line Tutorial.</p>
</subsection>
<subsection name="3.3.4 Setup Automatic Primary Key Generation">
<p>See step 3.2.4 from Command Line Tutorial.</p>
</subsection>
<subsection name="3.3.5 Generate Java Code for DataObjects">
<p>See step 3.2.5 from Command Line Tutorial.</p>
</subsection>
<subsection name="3.3.6 Compile and Deploy the Application">
<p>Compile the source code like you would normally compile
a webapplication. The example is given for javac from
the command line (assuming that JAVA_HOME variable
points to the JDK 1.3 or 1.4 installation). Substitute
<code>[servlet.jar]</code> with the path to the actiual
JAR file, for instance tomcat/common/lib/servlet.jar On
Windows:</p>
<source><![CDATA[
cayenne-web-app> cd WEB-INF\classes
classes> set CLASSPATH=%CLASSPATH%;[servlet.jar]
classes> set CLASSPATH=%CLASSPATH%;..\lib\struts.jar;..\lib\cayenne.jar
classes> %JAVA_HOME%\bin\javac webtest\*.java formbean\*.java action\*.java]]></source>
<p>On UNIX:</p>
<source><![CDATA[
cayenne-web-app# cd WEB-INF/classes
classes# export CLASSPATH=$CLASSPATH:[servlet.jar]:../lib/struts.jar:../lib/cayenne.jar
classes# $JAVA_HOME/bin/javac webtest/*.java formbean/*.java action/*.java]]></source>
<p>To deploy, simply copy <code>cayenne-web-app</code>
directory to Tomcat <code>webapps</code> directory and
restart the Tomcat. URL of the new applications is <a
href=
"http://localhost:8080/cayenne-web-app/">http://localhost:8080/cayenne-web-app/</a>
(on containers other then Tomcat, this will be
different). </p>
</subsection>
</subsection>
</section>
</body>
</document>