Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

outerPages.xml

00001 <?xml version="1.0" encoding="ISO-8859-1"?>
00002 
00003 <!-- The JWAA Outer Pages contain the website documentation; the pages
00004 that must be accessible without going through the login portal. 
00005 xmlns="http://www.w3.org/1999/xhtml"
00006 xmlns:jwaa="http://virtualschool.edu/jwaa.dtd"
00007 -->
00008 <pages 
00009   title="JWAA Web Application Architecture"
00010 >
00011 
00012 <page id="OUTER" name="JWAA" requiresRole="none"
00013   title="Java Web Application Architecture (JWAA)"
00014 >
00015   <child idref="INSTALLATION"/>
00016   <child idref="DOCUMENTATION"/>
00017   <child idref="SOURCE"/> 
00018   <child idref="CHANGES"/> 
00019   <child idref="LICENSE"/> 
00020   <child idref="PORTAL"/>
00021 
00022   <img align="right" src="/jwaa/pix/mvc.gif" alt="" width="117" height="114"/>
00023 
00024   <p>
00025     JWAA is a small but powerful architecture for writing web-based 
00026     applications in 
00027     <a idref="XHTML">XHTML</a>,
00028     <a idref="Velocity">Velocity</a> and <a idref="Java">Java</a>.
00029     JWAA is portable, <a idref="LICENSE">open source</a> (free) 
00030     code that is available for <a href="#download">download here</a>.
00031   </p>
00032 
00033   <p>
00034     JWAA features a fully object-oriented approach.  Applications 
00035     are networks of <i>page</i> objects that reference other pages 
00036     via standard object referencing semantics, not with text strings 
00037     buried in HTML text. JWAA brings the power of object-oriented 
00038     programming to bear on the web.
00039   </p>
00040 
00041   <br clear="all"/>
00042 
00043 <h2>Reduced Navigation</h2>
00044 
00045   <p>
00046     JWAA represents pages as XML files, not as conventional HTML files.
00047     XML's well-known abilities as a general purpose data representation 
00048     language are used to express entire web applications in only a few 
00049     files.  For example, the JWAA website is defined by three XML files: 
00050     <a idref="application.xml">application.xml</a>,
00051     <a idref="outerPages.xml">outerPages.xml</a> and
00052     <a idref="innerPages.xml">innerPages.xml</a>.
00053     The number of files is determined your application.xml 
00054     file, not by HTML-imposed restrictions.
00055   </p>
00056 
00057 <h2>Automatic reloading</h2>
00058 
00059   <p>
00060     JWAA monitors all input files for changes and automatically 
00061     reloads them when they change. Any errors are reported via 
00062     the browser when the XML file is first loaded, not buried 
00063     in an obscure log file.
00064   </p>
00065 
00066 <h2>Invalid link detection</h2>
00067 
00068   <p>
00069     Invalid links are automatically detected and reported when each
00070     application is first loaded. The id of each page is automatically 
00071     recorded in a dictionary and can be referenced by idref attributes
00072     as described below.  The dictionary can be expanded to add links to 
00073     external pages via dictionary elements in the application.xml file.  
00074     Dictionary entries are referenced by providing idref attributes 
00075     to the usual &lt;a&gt; and &lt;img&gt; XHTML commands.
00076   </p>
00077     
00078 <h2>Persistent forms</h2>
00079 
00080   <p>
00081     HTML lets you define forms that the user can type information into,
00082     but no way to store or process this information. That requires
00083     installing and learning languages, tools and environments that 
00084     bear no resemblance to HTML. The learning process is <i>discontinuous</i>.
00085   </p>
00086 
00087   <p>
00088     JWAA supports <a idref="FORMS">persistent forms</a> by default.  
00089     Like blackboards or paper, forms retain what the user writes 
00090     in them until it is explicitly changed or erased. Persistent forms 
00091     are a key building block for building form-based database-centric 
00092     applications such as wikis, quizzes, interview forms, and 
00093     so forth, often without any custom programming at all.  
00094     The default behavior is easily overridden.
00095   </p>
00096     
00097   <p>
00098     This feature was developed within the <a idref="ALE">Action Learning 
00099     Environment</a>, a JWAA application. It has been ported to JWAA on 
00100     as an experiment to investigate whether it makes sense to support
00101     persistent forms at a lower level.
00102   </p>
00103 
00104 <h2>Self documenting</h2>
00105 
00106   <p>
00107     Other environments provide a bare foundation to build on from
00108     first principles.  JWAA provides a finished environment to live 
00109     in and learn from while you remodel it to suit. Building a new
00110     application is a matter of copying the application that provides
00111     this tutorial and changing it to suit, learning new skills as you go.
00112   </p>
00113 
00114 <h2>Continuous learning</h2>
00115 
00116   <p>
00117     Ordinary HTML pages are static data files that are served 
00118     by a separate program such as Apache. That's fine until 
00119     the pages must support dynamic features when the learning 
00120     curve becomes discontinuous since new and unfamilar tools 
00121     must be installed and learned (perl or java, servlet 
00122     engines, etc).  
00123   </p>
00124 
00125   <p>
00126     JWAA provides a uniform and comprehensive XML-based environment 
00127     in which the transition from static to dynamic pages is continuous. 
00128     Simple static pages differ from advanced dynamic ones only in that 
00129     they don't use features that the same environment provides.
00130   </p>
00131 
00132 <h2>Automatic session management via cookies and/or URL rewriting</h2>
00133 
00134   <p>
00135     If the browser supports cookies, JWAA uses them to support session
00136     management. Otherwise JWAA will automatically rewrite all URLs 
00137     so that session information is retained when the user clicks 
00138     a URL. The code that rewrites URLs is actually provided by 
00139     the servlet engine. JWAA's contribution is to guarantee that 
00140     all URLs are subject to URL-rewriting, even those that 
00141     are buried in hardcoded &lt;a href="..."&gt; strings.
00142   </p>
00143 
00144 <h2>Integration <i>and</i> Separation of Concerns</h2>
00145 
00146   <p>
00147     JWAA supports both. When used with the 
00148     <a idref="Java+">Java+ preprocessor</a>, HTML is written as
00149     Java+ strings so that presentation and logic are combined
00150     and executable inclusions are expressed in plain Java. 
00151     The HTML can also be written as XML (XHTML) files and 
00152     automatically reloaded when they change, with executable 
00153     inclusions written in <a idref="Velocity">Velocity</a>.
00154     Since <a idref="Java+">Java+</a> now has its own web site, 
00155     this site will emphasize the XML-based approach.
00156   </p>
00157 
00158 <h2>Consistent Look and Feel</h2>
00159 
00160   <p>
00161     Navigation bars, background colors, and headers/footer 
00162     information on this and all other pages in this website 
00163     constitute this application's look and feel.  The look 
00164     and feel is defined by <a idref="Velocity">Velocity</a> 
00165     macros such that the look and feel is centrally defined
00166     and easily changed.  These macros are, by default, 
00167     automatically reloaded when the file that defines
00168     them is changed.
00169   </p>
00170 
00171 <h2>Model-View-Controller Paradigm plus Fields</h2>
00172 
00173   <p>
00174     JWAA pages are objects that supports a user's interaction with 
00175     internal objects, called Models (or JavaBeans). Model objects
00176     manage the application's persistent state, typically but not 
00177     necessarily as records in a database. By convention, model 
00178     objects' fields are not primitive Java datatypes like Strings. 
00179     Rather <b>fields</b> are the atoms from which models are composed.  
00180     Fields encapsulate the logic for validating user inputs, reporting 
00181     any problems by collaborating via the user interface. Fields are an 
00182     unusually powerful unit of reuse because they are tangible, concrete 
00183     and highly visible right in the application's user interface. 
00184     JWAA includes a comprehensive library of ready-to-use fields for
00185     building model objects in Java.
00186   </p>
00187 
00188 <h2>Small, Fast, Secure</h2>
00189 
00190   <p>
00191     With Java+, applications are constructed entirely at compile
00192     time and are remarkably small. JWAA's core functionality (minus 
00193     documentation and demos) is only 67kb while JSP is many times 
00194     larger. No compilers are needed on deployment servers, so speed,
00195     space and security are substantially improved.
00196   </p>
00197 
00198 <h2>Open Source</h2>
00199 
00200   <p>
00201     JWAA is <a idref="LICENSE">open source</a> (free) software, written 
00202     entirely in Java so it is automatically portable to any platform.
00203   </p>
00204 
00205 <a name="download"></a>
00206 <h2>Download Instructions</h2>
00207 
00208   <p>
00209     The JWAA distribution is <a href="/jwaa/jwaa.tgz">jwaa.tgz</a>.
00210     This is a gzipped tar file with the documentation, sources, compiled 
00211     binary, plus all required libraries except for four prerequisites
00212     that can be downloaded from the provided links.
00213   </p>
00214   
00215   <ul>
00216     <li>Web server (<a idref="Apache">Apache</a>)</li>
00217     <li>Relational Database (<a idref="MySQL">MySQL</a>)</li>
00218     <li>Java Software Development Kit (<a idref="Java">java.sun.com</a>)</li>
00219     <li>Servlet engine (<a idref="Jetty">Jetty</a> or <a idref="Tomcat">Tomcat</a>).</li>
00220   </ul>
00221 
00222   <p>
00223     See the <a idref="INSTALLATION">installation instructions</a>
00224     for how to proceed once you have the prerequisite software.
00225   </p>
00226 
00227 <h2>JWAA Applications</h2>
00228 
00229   <p>
00230     <a idref="Mybank">Mybank</a> is an ambitious digital rights
00231     management system based on <a idref="JWAA">JWAA</a> and 
00232     <a idref="Java+">Java+</a>.  
00233   </p>
00234     
00235   <p>
00236     <a idref="ALE">ALE</a> (Action Learing Environment) pioneered the 
00237     XML-based approach that was subsequently absorbed into its JWAA 
00238     substrate.  
00239   </p>
00240 
00241   <p>
00242     <a idref="ILE">ILE</a> (Interactive Learning Environment) is
00243     an ancestor of ALE that involved porting JWAA from Java to Ruby.  
00244     This project is now inactive because a servlet engine problem 
00245     that surfaced during the move to a new collocation provider.
00246   </p>
00247 
00248 </page>
00249 
00250 <page id="DOCUMENTATION" name="Documentation" requiresRole="none"
00251 title="Building web applications with JWAA" >
00252 <child idref="APPLICATIONS"/>
00253 <child idref="LOOKANDFEEL"/>
00254 <child idref="FORMS"/>
00255 <child idref="VELOCITY"/>
00256 <child idref="JAVA"/>
00257 
00258 <p>
00259   This documentation is divided into sections according to
00260   different levels of programming expertise:
00261 </p>
00262 
00263   <ol>
00264 
00265     <li>
00266       <a idref="APPLICATIONS">Application Builders</a> write the 
00267       static HTML content of an application by authoring them
00268       in XHTML gathered into Jwaa's XML format.
00269     </li>
00270 
00271     <li>
00272       <a idref="LOOKANDFEEL">Look and Feel Specialists</a> 
00273       define the look and feel for an application by revising the Velocity 
00274       macros and CSS (Cascading Style Sheets) that are provided.
00275     </li>
00276 
00277     <li>
00278       <a idref="VELOCITY">Interaction Specialists</a>
00279       make pages interactive by adding statements in the Velocity 
00280       programming language.
00281     </li>
00282 
00283     <li>
00284       <a idref="JAVA">Java Programmers</a> 
00285       use this section for extending the Java backend of this system.
00286     </li>
00287 
00288   </ol>
00289 
00290 </page>
00291 
00292 <page id="APPLICATIONS" name="Applications" requiresRole="none"
00293   title="Building a new JWAA Application" >
00294 
00295   <p>
00296     JWAA is capable of running multiple applications simultaneously.  
00297     Each application is defined by its own sub-directory of the 
00298     jwaa/root directory. Each application directory is required to
00299     provide a <a idref="application.xml">application.xml</a> file
00300     that points to the other files that make up that application.
00301   </p>
00302 
00303 <h2>The root/applicationName directory</h2>
00304 
00305   <p>
00306     For example, the pages you're reading now are provided by a JWAA
00307     application named "jwaa". This application is defined by the 
00308     root/jwaa directory. To build a new application, you simply 
00309     copy the root/jwaa directory to a new name and modify its contents 
00310     to be what you need. Don't change the jwaa directory.  Leave that 
00311     as it is to keep it is available for reference.
00312   </p>
00313 
00314   <p>
00315     The directory name determines the internal id of the application
00316     which determines the applicaton's URL. The first two components of 
00317     the url are defined by WEB-INF/web.xml as jwaa/xml. The third 
00318     component is application id, which is determined by the root 
00319     subdirectory name.  This tutorial is stored in root/jwaa, so the 
00320     tutorial application's id is jwaa.  Thus the jwaa tutorial's full
00321     URL is http://localhost/jwaa/xml/jwaa.
00322   </p>
00323 
00324   <p>
00325     These conventions are entirely governed by configuration files
00326     (typically etc/httpd/conf/httpd.conf and jwaa/WEB-INF/web.xml)
00327     so they can be easily changed according to the usual web server 
00328     and servlet engine conventions. To simplify this discussion, 
00329     these documents assume that the default settings are used.
00330   </p>
00331 
00332 <h2>application.xml</h2>
00333 
00334   <p>
00335     Right click on <a idref="application.xml">this link</a> 
00336     to open jwaa/root/jwaa/application.xml in a new browser window. 
00337     Notice that it specifies other files in the application's root 
00338     directory. 
00339   </p>
00340 
00341   <p>
00342     Notice that application.xml specifies two pages elements 
00343     with the ids outer and inner. The path attribute of these 
00344     elements specify the two files that define the jwaa application,
00345     outerPages.xml and innerPages.xml.  This discussion will be 
00346     concerned with outerPages.xml which defines the pages
00347     you're reading now. The other involves interactive features 
00348     that will be described separately.
00349   </p>
00350 
00351   <p>
00352     Each application's directory is contains an 
00353     <a idref="application.xml">application.xml</a> file that 
00354     specifies where other application components are stored. Open 
00355     that file now (right click to open it in a separate browser window). 
00356     Notice that three lines at the top specify the files that define 
00357     the JWAA documentation and the tutorial demonstration application.
00358   </p>
00359 
00360   <p>
00361     The macros element specifies the name of the file that defines
00362     the velocity macros (we'll be concerned with these in the
00363     next section), and the role element(s) designate the login ids
00364     that are able to access special administrative pages that
00365     are invisible (and unreachable) by ordinary users. We'll 
00366     describe those after we cover how ordinary static HTML
00367     content pages are defined.
00368   </p>
00369 
00370 <h2>Content Pages</h2>
00371 
00372   <p>
00373     Traditional pages are HTML files.  Jwaa pages, by contrast, are
00374     defined as elements inside XML files. Unlike HTML, each XML file
00375     file can define any number of pages.  The jwaa tutorial application 
00376     is defined by precisely two such files:
00377   </p>
00378 
00379   <ul>
00380 
00381     <li>
00382       <a idref="outerPages.xml">outerPages.xml</a> defines 
00383       the pages you're reading now. They are "outer" in the sense that they 
00384       lie outside of the demonstration application's login procedure.
00385     </li>
00386 
00387     <li>
00388       <a idref="innerPages.xml">innerPages.xml</a> defines 
00389       the pages of the demonstration application.  These are "inner" 
00390       in the sense that they cannot be accessed without registering 
00391       and logging in to the demonstration application. Most of these
00392       pages involve forms processing and will be described separately,
00393       under <a idref="FORMS">Forms Processing</a>.
00394     </li>
00395 
00396   </ul>
00397 
00398   <p>
00399     Which pages are defined in which files is arbitrary and entirely 
00400     up to the author's discretion. There is no significance to which 
00401     XML file a page is defined in. Page identifiers are maintained in 
00402     a single name space for each application, and the pages of that 
00403     application can reference each other freely, without concern for 
00404     which file they originated in.
00405   </p>
00406 
00407   <p>
00408     For example, open <a idref="outerPages.xml">outerPages.xml</a> 
00409     (right-click to open it in a separate window so you can continue
00410     reading these instructions).
00411     Notice that consists of a single large &lt;pages&gt;...&lt;/pages&gt; 
00412     (plural) element, that contains many &lt;page&gt;...&lt;/page&gt; 
00413     (singular) elements, each of which defines three attributes: 
00414   </p>
00415 
00416   <ul>
00417 
00418     <li>
00419       id: This is a string that will identifies the page to other pages.
00420       I recommend using uppercase identifiers to make them easy to find 
00421       with string searches.  
00422     </li>
00423 
00424     <li>
00425       name: This is the short name of the page as far as the end-user
00426       is concerned. It is visible in navigational menus, so keep it short 
00427       and meaningful.
00428     </li>
00429 
00430     <li>
00431       title: A longer string that will be presented at the top of each
00432       page as a &lt;h1&gt; header, and also as a title="" attribute in
00433       menu bars (which some browsers will present as a non-standard but
00434       useful rollover effect).
00435     </li>
00436 
00437   </ul>
00438 
00439   <p>
00440     The text within each page element is what'd normally goes in an 
00441     XHTML &lt;body&gt; element. The main difference is that they are 
00442     XHTML commands, not HTML commands.  They must comply with the 
00443     XHTML syntax requirements which are similar to HTML, but far 
00444     more strict. These differences are described <a idref="XHTML">here</a>.
00445   </p>
00446 
00447 <h2>Building a new application</h2>
00448 
00449   <p>
00450     To build a new application, copy an existing one and modify it 
00451     to suit. So begin by copying jwaa/root/jwaa to jwaa/root/myapp. 
00452     In your browser's location bar, replace the second jwaa with myapp 
00453     and click reload.  There will be a short delay as Jwaa loads the XML 
00454     files into memory, the page you're reading now will appear.  
00455     Click reload and notice that the page reloads much faster.
00456     The JWAA servlet continually watches the root directory for 
00457     new arrivals, so new arrivals are automatically on the air.
00458   </p>
00459 
00460   <p>
00461     Open jwaa/root/myapp/outerPages.xml in your text editor
00462     and search for the string <code>id="APPLICATIONS"</code>, which
00463     defines the page you're reading now. Insert a word or two in the 
00464     first paragraph, save the file, and click reload.  Notice that 
00465     the change appears in your browser window after a much shorter delay
00466     since only one file had to be reloaded for this change.
00467   </p>
00468 
00469 <h2>Correcting errors</h2>
00470 
00471   <p>
00472     The biggest difference between HTML and XHTML is that XHTML
00473     imposes strict syntax requirements. To see this in action,
00474     use your text editor to damage the file slightly (for example, by
00475     deleting the opening &lt;p&gt;). Save the result (but don't exit
00476     your text editor), and click reload in your browser. The browser 
00477     provides an error message pinpointing the error and requiring
00478     you to fix it.  Use your editor's undo function to repair
00479     the damage and reload the page in your browser to verify that
00480     the page now loads fine.
00481   </p>
00482 
00483 <h2>Required Pages</h2>
00484 
00485   <p>
00486     The only requirement JWAA does impose is that each application
00487     must define certain pages that the hard-coded part of the system
00488     refers to. These required identifiers are:
00489   </p>
00490 
00491   <ol>
00492 
00493     <li>
00494       OuterHomePage: The outer home page for the application as a whole.</li>
00495 
00496     <li>
00497       InnerHomePage: The inner home page. The first page a visitor
00498       sees when they pass the login procedure.
00499     </li>
00500 
00501     <li>
00502       PortalPage: The login and registration initiation page.
00503     </li>
00504 
00505     <li>
00506       NotFoundPage: A page to be displayed if a requested page is not
00507       found, for example, if the user mistyped the URL.
00508     </li>
00509 
00510     <li>
00511       RefusePage: A page to be displayed if the user requests a page
00512       their role doesn't allow them to see.
00513     </li>
00514 
00515   </ol>
00516 
00517     <p>
00518       Workable versions of these pages are all defined in innerPages.xml
00519       and will not concern us further here.
00520     </p>
00521 
00522   <h2>Optimizing for Production</h2>
00523 
00524     <p>
00525     The outer pages of an application don't usually change very often
00526     after they've been tested and installed, certainly not compared to 
00527     inner pages that might be computed almost entirely on the fly. 
00528     Furthermore outer pages are typically the ones you want to be 
00529     picked up and cataloged by search engines, unlike the inner ones.
00530   </p>
00531 
00532   <p>
00533     There are no firm rules as to which pages should be served dynamically,
00534     via the JWAA/Jetty servlet engine, versus which should be served
00535     statically by a web server. The practice I follow is to periodically
00536     save the application's OuterHomePage (dynamically generated) into
00537     an index.html file in the application's root directory, and to have
00538     all other pages refer to this static page instead of its dynamic
00539     address.
00540   </p>
00541 
00542   <p>
00543     For example, the dynamic version of JWAA's own home page is
00544     http://virtualschool.edu/jwaa/index.html. This is the page that
00545     is picked up by search engines, and is served as a static web 
00546     page by the apache web server. The same page is also accessible
00547     as a dynamically generated page at 
00548     http://virtualschool.edu/jwaa/xml/jwaa/OuterHomePage. The static
00549     version (index.html) is derived from the dynamic version by
00550     simply using the browser's saveAs function to update the static
00551     version when the dynamic version changes.
00552   </p>
00553 
00554 </page>
00555 
00556 <page id="LOOKANDFEEL" name="Look And Feel" requiresRole="none"
00557 title="Defining the application's Look and Feel"
00558 >
00559 
00560   <p>
00561     An application's look and feel is governed by the velocity.macros 
00562     file in the top level directory
00563     of your application, plus any the CSS (Cascading Style Sheet)
00564     definitions that the macros use, which are typically stored in
00565     your application's css directory in the same location. 
00566   </p>
00567 
00568   <p>
00569     For example, see the \#defaultLogic() and \#header macros in
00570     <a idref="velocity.macros">velocity.macros</a>. 
00571     Controller automatically inserts calls to these at the
00572     beginning of each page's text and a call to the \#footer()
00573     macro at the end. Velocity simply replaces the call statements 
00574     with the text defined in the macros.
00575   </p>
00576 
00577   <p>
00578     Make experimental changes to these macros (keep them simple for
00579     now) and reload the browser to observe the effect. Then browse
00580     several pages and notice that changes to these macros have global 
00581     effects, automatically propagating to every page in your application.
00582   </p>
00583 
00584   <p>
00585     Notice that the \#header() macro includes a &lt;link command
00586     that tells the browser to load css/innerPage.css and
00587     css/print.css. These define additional page markup conventions
00588     that I also rely on to further adjust the application's look and
00589     feel. CSS markup is a separate topic that I'm still learning 
00590     myself. See the Reference list for more information on CSS.
00591   </p>
00592 
00593 <h2>References</h2>
00594 
00595   <ol>
00596 
00597     <li>
00598       <a href="http://jakarta.apache.org/velocity/user-guide.html"> 
00599       Velocity User's Guide</a> is the most relevant.
00600     </li>
00601 
00602     <li>
00603       <a href="http://www.w3schools.com/css/default.asp">CSS 
00604       Tutorial</a> by W3Schools.
00605       </li>
00606 
00607   </ol>
00608 
00609 </page>
00610 
00611 <page id="FORMS" name="Forms" requiresRole="none"
00612   title="Persistent Forms" >
00613 
00614   <p>
00615     Forms are defined with the usual XHTML form, input and select
00616     statements... with important differences stemming from the
00617     need to not only define the form presentation (as in XHTML),
00618     but also logic for processing that form once submitted.
00619   </p>
00620 
00621   <p>
00622     Persistent form support is under development and rapidly changing.  
00623     I'll upgrade this documentation as the design stabilizes.  See the 
00624     PORTAL and UPDATE pages of <a idref="innerPages.xml">innerPages.xml</a> 
00625     for how to code forms in the traditional (manual) way within JWAA.
00626   </p>
00627 
00628 <h2>Persistent Form Example</h2>
00629 
00630   <p>
00631     See the FORMS element in <a idref="outerPages.xml">outerPages.xml</a>
00632     for this test case for the persistent forms feature.
00633   </p>
00634 
00635   <form id="DEMO_FORM">
00636     <logic>
00637 #set($op = $form.getValue("op"))
00638 #if ($op)
00639     $form.save()
00640     #if ($op eq "Prev")
00641       $self.gotoPage($self.getPrevPage().getId())
00642     #elseif ($op eq "Next")
00643       $self.gotoPage($self.getNextPage().getId())
00644     #end
00645 #end
00646     </logic>
00647 
00648     <table align="center">
00649       <tr>
00650         <td>Text Fields </td>
00651         <td>
00652           <input name="textField" type="text" />
00653         </td>
00654       </tr>
00655       <tr>
00656         <td>Password Fields </td>
00657         <td>
00658           <input name="passwordField" type="password" />
00659         </td>
00660       </tr>
00661       <tr>
00662         <td>Radio Selection Fields </td>
00663         <td>
00664           <input name="radioFieldName" value="Yes" type="radio"/> Yes
00665           <input name="radioFieldName" value="No" type="radio"/> No
00666           <input name="radioFieldName" value="Maybe" type="radio"/> Maybe
00667         </td>
00668       </tr>
00669       <tr>
00670         <td>Checkbox Fields </td>
00671         <td>
00672           <input name="checkboxField" value="Yes" type="checkbox"/> Yes
00673           <input name="checkboxField" value="No" type="checkbox"/> No
00674           <input name="checkboxField" value="Maybe" type="checkbox"/> Maybe
00675         </td>
00676       </tr>
00677       <tr>
00678         <td>Single Selection Fields</td>
00679         <td>
00680           <select name="singleSelectionField">
00681             <option>Yes</option>
00682             <option>No</option>
00683             <option>Maybe</option>
00684           </select>
00685         </td>
00686       </tr>
00687       <tr>
00688         <td>Multiple Selection Fields </td>
00689         <td>
00690           <select name="multipleSelectionField" multiple="multiple">
00691             <option>Yes</option>
00692             <option>No</option>
00693             <option>Maybe</option>
00694           </select>
00695         </td>
00696       </tr>
00697       <tr>
00698         <td> Text Area Fields </td>
00699         <td>
00700           <textarea name="textareaField" rows="2" cols="15"></textarea>
00701         </td>
00702       </tr>
00703       <tr>
00704         <td>Submit Buttons </td>
00705         <td>
00706           <input name="op" value="Prev" type="submit"/>
00707           <input name="op" value="Save" type="submit"/>
00708           <input name="op" value="Next" type="submit"/>
00709         </td>
00710       </tr>
00711     </table>
00712 
00713   </form>
00714 
00715   <p>
00716     To try it, change the field contents, click one of the Submit 
00717     buttons and notice that the changes persist when you return,
00718     just as the information on paper remains when you look at it later. 
00719   </p>
00720 
00721   <p>
00722     If the server is heavily loaded, what you see depends on 
00723     whether you've logged (via the <a idref="PORTAL">Demo login screen</a>).  
00724     Visitors who haven't logged in share the same account and 
00725     their modifications to persistent forms affect the same
00726     database records, so persistent form contents will be as 
00727     the last visitor set them.  So if you're not logged in, 
00728     persistent forms behaves like blackboards that can be 
00729     read, written on, or erased by anyone that walks by. 
00730     If you have logged in, forms behave like paper that is
00731     under your sole control.  We assume both cases are 
00732     potentially useful.
00733   </p>
00734 
00735   <p>
00736     The contents of each field persist as records in a relational 
00737     database (MySQL) keyed with the page id, the field name, and
00738     the user's ID. Users who have not logged in via the 
00739     <a idref="PORTAL">Demo login screen</a> share the same account
00740     and have concurrent access to the same database fields.  JWAA
00741     does not prevent such users from overwriting each other's work
00742     on the grounds that blackboards and paper have the same liability
00743     but are still useful in education.
00744   </p>
00745 
00746   <p>
00747     The persistence feature applies only to form elements that
00748     do <i>not</i> define explicit values. It does not apply
00749     to text or password fields with value attributes, to checkbox,
00750     radio, and select fields with checked attributes and so forth).
00751     It can be turned off in forms that should not be persistent 
00752     (login screens and so forth) by simply defining explicit values.
00753   </p>
00754 
00755 <h2>Unresolved Issues</h2>
00756 
00757   <p>
00758     I'm eager to support persistence at the lowest architectural 
00759     level because persistent forms are such a powerful unit of 
00760     reuse... for exactly the same reasons that paper and blackboards
00761     are so useful in education. They are lowest-level building blocks 
00762     that support many concrete interactive applications. I've 
00763     supported them experimentally to validate the truth of this
00764     claim in practice.
00765   </p>
00766 
00767   <p>
00768     By contrast, <a idref="ALE">ALE</a> provides workflow features 
00769     that model the paper workflow in classrooms. The instructor develops
00770     quizzes and passes them to students, who write answers on them and 
00771     return them to the teacher, who grades them and returns them to students
00772     to read the teacher's feedback.  ALE's support for such workflow 
00773     has not been ported to JWAA because that is clearly inappropriate
00774     at JWAA's level.  
00775   </p>
00776 
00777   <p>
00778     I'm not sure of where to draw this boundary. So the persistent
00779     forms feature has been added provisionally. The goal is to 
00780     investigate whether persistent forms belong at the JWAA level 
00781     in the absence of ALE's workflow support. If not, I'll 
00782     remove it from JWAA and support it only within ALE.
00783   </p>
00784 
00785   <p>
00786     I'm not entirely satisfied with how navigational controls (the Prev,
00787     Save, and Next buttons in this example) are handled. ALE provides 
00788     these automatically and consistently as part of its workflow 
00789     support, so no effort is needed to present them everywhere they 
00790     are needed.  This can't be done at JWAA's level since the default 
00791     navigational controls would clash with the user's page design.
00792   </p>
00793 
00794   <p>
00795     I welcome other opinions on these issues.  Share them via email with
00796     <a href="mailto:bcox@virtualschool.edu">bcox@virtualschool.edu</a>.
00797   </p>
00798 
00799 </page>
00800 
00801 <page id="VELOCITY" name="Velocity" requiresRole="none"
00802   title="Programming with Velocity">
00803 
00804   <p>
00805     Velocity is a language for accessing objects provided
00806     to it by the Java part of the system. The following objects 
00807     are automatically available to velocity code via velocity's
00808     "context".  For further information see the 
00809     <a idref="ObjectReferenceManual">ObjectReferenceManual</a>.
00810   </p>
00811 
00812   <dl>
00813 
00814     <dt>\$self</dt>
00815 
00816     <dd>
00817       \$self provides access to the <a idref="Controller">Controller</a>
00818       for the page that is currently being displayed. The controller 
00819       provides methods that velocity scripts use to access other objects 
00820       in the page's neighborhood, such as 
00821       the <a idref="PageElement">PageElement</a> that defines this page,
00822       the <a idref="PagesElement">PagesElement</a> in which this page
00823       was defined, 
00824       the page's <a idref="ApplicationElement">ApplicationElement</a>, 
00825       and more. 
00826     </dd>
00827 
00828     <dt>\$account</dt>
00829 
00830     <dd>
00831       \$account provides access to information about the account
00832       that is currently logged in. From this you can determine
00833       their name, address, phone number, and similar information 
00834       from the registration procedure.
00835     </dd>
00836 
00837     <dt>\$dbms</dt>
00838 
00839     <dd>
00840       Each application maintains a pool of connections to the
00841       application's database as a <a idref="DBPool">DBPool</a> 
00842       instance. The controller automatically withdraws a database 
00843       connection (a <a idref="DB">DB</a> instance) from the pool 
00844       and makes that instance available to velocity code as the 
00845       $dbms context variable. 
00846     </dd>
00847       
00848     <dd>
00849       Your code can use this variable to access the database by 
00850       calling the public methods that DB provides for this purpose. 
00851       The controller automatically either commits any transactions 
00852       that finish successfully (and rolls back those those that 
00853       fail; i.e. those that throw exceptions). Finally it returns
00854       the DB instance to the pool for reuse.
00855     </dd>
00856 
00857     <dt>$form</dt>
00858 
00859     <dd>
00860       The $form variable is null if the page contains no &lt;form&gt;
00861       element and an instance of <a idref="FormElement">FormElement</a>
00862       if it does. This may change in future releases such that form
00863       elements can be accessed via the \$self or \$self.page variables.
00864     </dd>
00865 
00866   </dl>
00867 
00868 <h2>Velocity Hints</h2>
00869 
00870   <p>
00871     Velocity statements like \$self.application don't access 
00872     the Controller's "application" field directly. Velocity 
00873     automatically treats such statements as if written
00874     \$self.getApplication(), which calls the Controller's 
00875     getApplication() method to return the value.  In other 
00876     words, fields are never accessed by Velocity code, 
00877     only methods, and then only those methods that 
00878     are explicitly public.
00879   </p>
00880 
00881   <p>
00882     But always remember that methods are general-purpose functions
00883     that can (and often do) make permanent changes to their environment.
00884     Such methods are said to have <i>side-effects</i>. This is actually
00885     quite useful, for it is how velocity scripts affect their environment.
00886   </p>
00887 
00888 </page>
00889 
00890 
00891 <page id="JAVA" name="Java" requiresRole="none" title="Java Programmer's Guide" >
00892   <child idref="OVERVIEW" />
00893   <child idref="MODELS" />
00894   <child idref="FIELDS" />
00895   <child idref="ROLES" />
00896 
00897 <p>
00898   Simple JWAA websites can be built entirely in XML and Velocity, without 
00899   exploring the Java end of this system more deeply than reading the
00900   <a idref="ObjectReferenceManual">ObjectReferenceManual</a> for Java 
00901   class descriptions.  However the Java source code must be documented 
00902   for those who wish to explore it.  And some things, such as extending 
00903   the system with new persistent objects, are only really practical in 
00904   Java.
00905 </p>
00906 
00907 <h2>Prerequisites</h2>
00908 
00909 <p>
00910   Begin by downloading and installing the following tools from the
00911   specified links:
00912 </p>
00913 
00914 <ol>
00915 
00916   <li>
00917     <a idref="Eclipse">Eclipse</a>: Eclipse is the main tool for
00918     reading Java source code, making changes, correcting mistakes,
00919     compiling source code to executable class files, debugging 
00920     running programs, and viewing data structures 
00921     while the program is running. The best version to download
00922     is version 2.1.1: the later "milestone" versions are too 
00923     buggy to count on in my experience. Also avoid plugins:
00924     they are even more problematic than eclipse.
00925   </li>
00926 
00927   <li>
00928     <a idref="Ant">Ant</a>: Ant is a command line tool that is
00929     used for everything Eclipse doesn't do: compiling documentation
00930     from source code (via doxygen), building jar files from 
00931     individual class files, copying files from the build directory
00932     to the deployment directory, maintaining backup copies, 
00933     building distribution (.tgz) files, and so forth. 
00934   </li>
00935 
00936 </ol>
00937 
00938 <p>
00939   Install ant and eclipse where ever you please (I use /opt)
00940   and make scripts to launch them conveniently. Here's the script 
00941   I use for launching eclipse (the Fixme comment marks
00942   two lines to edit to suit your system).
00943 </p>
00944 
00945 <pre>
00946 #!/bin/sh
00947 
00948 # Fixme
00949 ECLIPSE_DIR=/opt/eclipse-2.1.1
00950 WORKSPACE_DIR=~/workspace
00951 
00952 # Launch eclipse
00953 cd $WORKSPACE_DIR
00954 $ECLIPSE_DIR/eclipse -data $WORKSPACE_DIR $* &amp;
00955 echo $ECLIPSE_DIR starting ... 
00956 </pre>
00957 
00958 <p>
00959   The WORKSPACE_DIR line overrides eclipse's annoying behavior
00960   of creating a default workspace inside eclipse's program 
00961   directory. "Workspace" in eclipse's term for the directory
00962   that it uses to store <b>your</b> source code. Its not eclipse's
00963   code, its <b>yours</b>, and you want to control where its stored
00964   rather than leaving that up to eclipse. My preference is for the
00965   workspace to be in my home directory which is where the default
00966   settings in the above script puts it.
00967 </p>
00968 
00969 <h2>Importing JWAA into Eclipse</h2>
00970 
00971 <p>
00972   Launch eclipse, pull down the Window menu, and choose 
00973   Preferences. Click the triangle by Java in the left panel
00974   to open it, click Compiler, and select the "Folders" option
00975   under "Source and output folder". Leave the default source
00976   folder name ("src") and output folder name ("bin") as they
00977   are.  Click "OK". Eclipse will now create new projects with 
00978   src and bin folders, which matches the convention I'll use in 
00979   this document.
00980 </p>
00981 
00982 <p>
00983   Right click in the left panel (Package Explorer) and click
00984   "New Project". Choose "Java" in the popup panel and click Next.
00985   Type "JWAA" as the project name and click Finish. JWAA will now
00986   appear in the left panel as a new but empty project.
00987 </p>
00988 
00989 <p>
00990   Right click on the JWAA project in the left pane and choose
00991   Import. Browse to the installed copy of JWAA, double-click it
00992   and JWAA should appear in the left pane with an empty checkbox.
00993   Eclipse is somewhat unreliable here; often the left pane doesn't
00994   change when you select a directory. Clicking the back button and
00995   advancing with the Next button appears to resolve it. Once JWAA
00996   appears in the left panel with the empty checkbox, click the 
00997   checkbox to select it and click finish. A red checkbox signifying
00998   compile errors will appear in the left panel. The errors are OK:
00999   you haven't defined libraries yet.
01000 </p>
01001 
01002 <p>
01003   Right-click on the imported project and choose Properties. In the
01004   left panel of the window that appears, click "Java Build Path".
01005   Select the Libraries pane and click "Add Jars". Click JWAA,
01006   then WEB-INF, then lib, and drag-select all of the jar files 
01007   that are offered there. Click OK. A few errors will remain
01008   because you've not provided the servlet engine's libraries yet.
01009 </p>
01010 
01011 <h2>Importing Jetty into Eclipse</h2>
01012 
01013 <p>
01014   Repeat all of the above steps to import Jetty into a separate
01015   "Jetty" project in your workspace. Use "Add Jars" in the Jetty
01016   project until Jetty compiles without errors. Right-click on your 
01017   JWAA project, choose Properties again, and this time select the
01018   "Projects" tab. Checkboxes for the JWAA and Jetty projects should
01019   appear there. Select the checkbox next to the Jetty project to
01020   specifies that Eclipse should use the bin directory of the Jetty
01021   project to resolve unsatisfied references in addition to the jar
01022   files you specified earlier.  JWAA should build now without errors 
01023   and the red mark in the left pane will disappear.
01024 </p>
01025 
01026 <p>
01027   Recall that Jetty refers to symbolic links (or outright copies)
01028   in its webapps subdirectory to determine which servlets it should
01029   load, and it expects each such link (or copy) to contain a WEB-INF
01030   directory.  When Eclipse copied Jetty to its workspace, it copied 
01031   Jetty's webapps directory along with the symbolic link you made earlier.
01032   This link points to the original copy of JWAA in the document root 
01033   directory. You want this copy of Jetty to load files from the
01034   copy of JWAA in your workspace. So delete the jwaa copy and replace 
01035   it with a new symbolic link to the JWAA in your workspace 
01036   directory, like this:
01037 </p>
01038 
01039 <pre>
01040 cd ~/workspace/Jetty/webapps
01041 # notice the old jwaa copy
01042 ls -l                         
01043 # remove the old jwaa copy
01044 rm -rf jwaa                   
01045 # create a symbolic link to workspace/jwaa
01046 ln -s ~/workspace/jwaa/ jwaa  
01047 </pre>
01048 
01049 <p>
01050   Jetty will load jar files from the WEB-INF/lib directory and 
01051   individual class files from the WEB-INF/classes directory.
01052   The WEB-INF/lib directory already contains a copy of the 
01053   jwaa.jar that came with the distribution. Since you'll be
01054   making changes to the jwaa source code, you want the changed
01055   versions to be loaded, not the original distributed version.
01056   The simplest way to ensure this is to create a symbolic link,
01057   named classes, in the WEB-INF directory that points to the
01058   bin directory in which Eclipse stores its generated files,
01059   like this:
01060 </p>
01061 
01062 <pre>
01063 cd ~/workspace/jwaa/WEB-INF
01064 ln -s ../bin classes
01065 </pre>
01066 
01067 <h2>Launching Jetty from inside Eclipse</h2>
01068 
01069 <p>
01070   Back to Eclipse now. Pull down the Run menu, choose
01071   Debug, and a window will appear. Under Main, in the
01072   Project area, click the Browse button and select the 
01073   Jetty project. In the "Main class" area, choose Search,
01074   and select org.mortbay.start.Main as the main routine
01075   Eclipse should invoke to launch Jetty.
01076 </p>
01077 
01078 <p>
01079   In the Arguments tab, type the full path to the jetty.xml
01080   file in Jetty's etc directory. This is 
01081   /home/bcox/workspace/jetty/etc/jetty.xml in my case.
01082 </p>
01083 
01084 <p>
01085   In the Classpath tab, use Add Jars to add all of the jars
01086   in Jetty's lib directory. Then use Add Projects to add
01087   all of the projects that you'll be working with, just jwaa
01088   in this case. 
01089 </p>
01090 
01091 <p>
01092   Finally, click Apply, then Debug. Jetty should launch 
01093   without errors and display its normal startup dialog 
01094   in the console window at the bottom of the screen. 
01095   If any errors are displayed, it is probably because these
01096   instructions missed a required jar. Another common problem
01097   is trying to run muliple copies of jetty, which won't work.
01098   You must shut down any external copies for the new one
01099   to launch.
01100 </p>
01101 
01102 <p>
01103   Jetty is now running within Eclipse, and JWAA is running as
01104   a servlet within Jetty, and all facilities of both are accessible
01105   to the Eclipse debugger. Confirm that JWAA is accessible within
01106   Jetty by opening a browser window on http://localhost/jwaa and
01107   confirming that browsing to subpages work as before.
01108 </p>
01109 
01110 <p>
01111   Now let's set a breakpoint. In the Java Source browser (click the
01112   J icon on the left edge, open the jwaa project (click the triangle),
01113   open its src folder, and open the edu.virtualschool.jwaa.xml folder.
01114   Double-click on Controller.java and view the source code in the middle 
01115   pane. In the right pane, click on the run() method, which is the
01116   code that services each page request. Find the line that reads
01117   "send(evalText)" near the end of this method, and double-click in
01118   the blue margin next to this method. A blue dot will appear, signifying
01119   that a breakpoint has been set on this statement. 
01120 </p>
01121 
01122 <p>
01123   In your browser, click any link to request a new page. Eclipse will
01124   switch automatically to its Debug view with the selected statement
01125   highlighted in a smaller source window. The window above that will
01126   show a backtrace of the method calls that led to this point. Click
01127   on these and observe that the source code shown in the bottom window
01128   changes to show the clicked method. Click on the run method again
01129   and notice that all variables that were scope at the point of the 
01130   breakpoint is available for browsing. For example, pageText shows
01131   the XML code for the selected page before it was processed by
01132   velocity, and evalText shows the text as processed by velocity
01133   just before the send() method sends it to the browser.
01134 </p>
01135 
01136 <p>
01137   In other words, every aspect of the program is exposed to view
01138   and subject to modification: not just the source code but the
01139   actual run-time data while the code is running. It can't be
01140   any easier than that!
01141 </p>
01142 
01143 </page>
01144 
01145 <page id="OVERVIEW" name="Overview" requiresRole="none" 
01146   title="Overview of the Java side of this system" >
01147 
01148 <p>
01149   See the <a idref="ObjectReferenceManual">ObjectReferenceManual</a> 
01150   for Java class descriptions.  This section provides an overview of 
01151   and suggestions for modifing and extending these classes.
01152 </p>
01153 
01154 <h2>Startup-time Processing</h2>
01155 
01156 <p>
01157   JWAA's main entry point is the init() method of 
01158   <a idref="JwaaServlet">JwaaServlet</a>, a subclass of 
01159   <a idref="GenericServlet">GenericServlet</a> from which it 
01160   inherits most of its methods.
01161 </p>
01162 
01163 <p>
01164   The JwaaServlet constructor initializes a dispatch
01165   table with a list of <a idref="MetaPage">MetaPage</a> 
01166   instances, one for each GenericServlet instance in the system. 
01167   With Java+, each page is an instance of Page and each defines 
01168   a MetaPage as a reference point for other pages to use when 
01169   emitting links to that page. When the XML feature of JWAA is 
01170   used, this table contains only a single instance; an instance of 
01171   <a idref="Controller">Controller</a> that is shared by all pages.  
01172   This instance serves as the controller for all JWAA pages, 
01173   dispatching requests in a manner similar to the usual JWAA 
01174   dispatching machinery, but based on the id defined for each
01175   page in the XML files.
01176 </p>
01177 
01178 <p>
01179   The init method retrieves several init parameters defined in
01180   the jwaa/WEB-INF/web.xml file and that locate the other parts
01181   of the system:
01182 </p>
01183 
01184 <ul>
01185 
01186   <li>
01187     url.prefix: This makes the application aware the URL prefix string. 
01188     This parameter should be hand-constructed by concatenating the 
01189     servlet name and url pattern (defined elsewhere in this file).
01190     By default, the servlet name is /jwaa and the url pattern is /xml/*,
01191     so the url.prefix is /jwaa/xml. Like all settings in this file,
01192     this can be changed if desired.
01193   </li>
01194 
01195   <li>
01196     home.directory: The absolute path to jwaa's installation directory.
01197     By default, this refers to a symbolic link in the system root
01198     directory, /jwaa, that points to the real installation directory.
01199   </li>
01200 
01201   <li>
01202     root.directory: The absolute path to jwaa's root directory.
01203     By default, /jwaa/root.
01204   </li>
01205 
01206   <li>
01207     properties.directory: The absolute path to the directory the
01208     class loader will load properties files from. By default,
01209     /jwaa/WEB-INF/classes.
01210   </li>
01211 
01212 </ul>
01213 
01214 <p>
01215   The init() method passes root.directory as an argument to
01216   the <a idref="RootDirectory">RootDirectory</a> class's constructor. Each 
01217   subdirectory of the jwaa/root directory is required to contain an
01218   application.xml file that locates any other files used
01219   by that application. The application.xml files are
01220   not loaded at init time. It and the files it refers to 
01221   are loaded when they are first referenced so that any 
01222   errors can be reported via the browser, not hidden in 
01223   log files.
01224 </p>
01225 
01226 <h2>Load-time Processing</h2>
01227 
01228 <p>
01229   The directory names in jwaa/root determine the id's for
01230   each application. Browser requests are of the form
01231   /jwaa/xml/applicationID/pageID.  The JwaaServlet doRequest
01232   method (inherited from GenericServlet) uses the /jwaa/xml 
01233   component as the key for a dispatch table lookup, which
01234   selects the (sole) dispatch table entry for Controller.
01235   If the search fails, the search returns 
01236   JwaaServlet.getDefaultPage(), which specifies the same
01237   class, so the MetaPage entry for Controller has no real
01238   signficance.
01239 </p>
01240 
01241 <p>
01242   The doRequest() method creates an instance of Controller
01243   calls that instance's init() method to initialize
01244   the instance with the MetaPage instance, servlet, 
01245   HttpRequest and HttpResponse, and calls the instance's
01246   run() method to handle the request.
01247 </p>
01248 
01249 <p>
01250   The instance's run method retrieves the servlet from its init 
01251   parameters and calls its getRoot() method to retrieve the root 
01252   object for that servlet. The rest of the request string
01253   (/applicationID/pageID) is passed to the root's findPath()
01254   method to determine the application and the page within
01255   that application. If the application is not found, an error
01256   is reported.
01257 </p>
01258 
01259 <p>
01260   XML loading is triggered from within the root object's findPath() 
01261   method. The <a idref="RootDirectory">RootDirectory</a> class maintains a HashMap
01262   of the application instances that it built when it last scanned
01263   the root directory and a <a idref="FileField">FileField</a>
01264   instance that records the root directory's path and last modification 
01265   time. If the current modtime is greater than the last modtime,
01266   the directory is rescanned, ensuring that new applicaions will be 
01267   noticed and added to the HashMap.
01268 </p>
01269 
01270 <p>
01271   The HashMap entries are instances of <a idref="ApplicationElement">ApplicationElement</a>
01272   each of which maintains the information specified in a specific application.xml
01273   file along, a FileField that records when that file was last changed, 
01274   and a list of <a idref="PagesElement">PagesElement</a> instances, one for each pages
01275   element in that file.  The FileField is examined each time that 
01276   instance's update() method is called. If the FileField is out of date, 
01277   Otherwise, the file is reloaded to pick up any changes. Either way, the
01278   update() request is conveyed to each PagesElement instance.
01279 </p>
01280 
01281 <p>
01282   Each PagesElement instance also maintains a FileField for its XML file
01283   and a list of the Page instances specified in that file. If the
01284   FileField is up to date, the update() request returns immediately.
01285   Otherwise the file is reloaded and the list of Page instances is
01286   rebuilt.
01287 </p>
01288 
01289 <p>
01290   XML file loading at all levels involves using JDOM in the usual
01291   manner to populate instance variables with the information conveyed
01292   in the file.
01293 </p>
01294 
01295 <h2>Dispatch-time Processing</h2>
01296 
01297 <p>
01298   Jetty calls JwaaServlet's (inherited) doRequest() method for
01299   each URL request that makes its way to the servlet engine from
01300   Apache. This includes only those that match the servlet-name
01301   and url-mapping defined in web.xml; all others are by 
01302   definition intercepted by Apache.
01303 </p>
01304 
01305 <p>
01306   The doRequest() method calls request.getRequestURI() to
01307   obtain the request URI from the request parameters. This is
01308   looked up in the (empty) dispatch table, which always fails, so
01309   JwaaServlet's getDefaultPage() method is called which always
01310   returns the metapage of Controller. JwaaServlet constructs an 
01311   instance of Controller and initializes it with the Controller's 
01312   metapage, the JwaaServlet instance, and the request/response 
01313   parameter objects). Finally the Controller's run method is called 
01314   to service the request.
01315 </p>
01316 
01317 <h2>Controller</h2>
01318 
01319 <p>
01320   Controller is the primary interface between the
01321   Java and Velocity sides of the system. It holds the execution
01322   state that governs communication with the browser
01323   (request/response and servlet parameters) and links to the page
01324   being served in this transaction. The page instance in turn
01325   references its container, a pages instance, which in turn
01326   references its parent, and so on, until the parent links
01327   converge on the application and thereby the parent of all applications,
01328   the RootDirectory object. In other words, the page instance can be
01329   traversed (via methods the Controller provides to make this
01330   convenient) to reach the other objects in the system.
01331 </p>
01332 
01333 <p>
01334   The Controller processes each request by passing the
01335   pathInfo string to the getPath() method of the RootDirectory instance,
01336   expecting a page instance in return. The RootDirectory instance breaks
01337   each request into (up to) three slash-separated identifiers;
01338   application, pages, and page. The application id specifies a
01339   application, the pages id is looked up in its pagesMap to
01340   determine a PagesElement instance, and the page id is looked
01341   up in its pageMap to determine the Page instance. If all three
01342   lookups succeed, the resulting Page instance is returned, else
01343   various shorthands and defaults are employed to ensure that a
01344   valid Page instance is always returned (although not 
01345   necessarily the one that the user requested).
01346 </p>
01347 
01348 <h2>XML Loading/Reloading</h2>
01349 
01350 <p>
01351   RootDirectory's getPath() method calls its update() method which
01352   handles loading of XML pages and reloading them when they are
01353   changed. Only four JWAA classes manage files directly: RootDirectory
01354   (which monitors application directory names, not files), 
01355   <a idref="ApplicationElement">ApplicationElement</a>
01356   <a idref="PagesElement">PagesElement</a> and 
01357   <a idref="PageElement">PageElement</a>.
01358   All others are derived from elements of the
01359   above files. These four classes each maintain a FileField
01360   instance that contains the path to the file and the last
01361   modification time of that file. Each update() compares this
01362   with the file's current modtime and reloads that object from 
01363   XML if the current modtime is greater than the stored one.
01364 </p>
01365 
01366 <p>
01367   The XML loading process is straightforward. The XML parsing
01368   involves using JDOM and the libraries that support it to
01369   parameterize constuctors for each of the Java model classes
01370   from XML attributes. The Page class's constructor walks the
01371   element tree completely, rewriting JDOM's question-and-answer
01372   elements into Velocity macro calls, then call's JDOM's
01373   Outputter class to convert its DOM tree to an ordinary string,
01374   which is mainted thereafter in an instance variable. No XML
01375   parsing occurs thereafter; its all done once when JWAA first 
01376   notices the file has changed.
01377 </p>
01378 
01379 <h2>Permission Checking</h2>
01380 
01381 <p>
01382   Once the Controller receives a Page instance from the RootDirectory
01383   lookup process, it compares the pages requiredCapability
01384   instance variable (it is set in the XML file) with the
01385   capabilities of the account requesting that page. If the account
01386   has the required capability, the access is allowed. Otherwise
01387   the page is replaced with the application's refuse page. (as
01388   shipped, JWAA's refuse page silently forwards the user to the
01389   login page, which I find less offensive than the usual "access 
01390   refused" alert and has much the same effect.)
01391 </p>
01392 
01393 <h2>Database Access</h2>
01394 
01395 <p>
01396   The Controller initializes an instance variable with a JDBC
01397   database connection from the connection pool (inside a try
01398   block with a finally clause to return it to the pool when
01399   finished with it). Then it uses that connection to initialize
01400   two HashMap variables, answerMap and reviewMap, with the
01401   answers to each question asked on that page, and the reviews of
01402   each answer, for the convience of the velocity macros that 
01403   present questions, answers, and reviews to the student.
01404 </p>
01405 
01406 <h2>Velocity Context</h2>
01407 
01408 <p>
01409   The Controller builds an instance of VelocityContext for
01410   each request and initializes it with (1) \$self: the Controller
01411   instance, (2) \$account: the account that is currently logged
01412   in, and (3) any form parameters.
01413 </p>
01414 
01415 <h2>Velocity Dispatching</h2>
01416 
01417 <p>
01418   Finally the page's text is retrieved from the Page instance
01419   and passed (with the context object) to an instance of
01420   VelocityEngine. Each application manages separate VelocityEngine
01421   instances so that each can have its own directory, 
01422   velocity.macros files, and so forth.
01423 </p>
01424 
01425 <p>
01426   The VelocityEngine essentially transforms the string passed
01427   to it by processing velocity commands embedded therein against
01428   the context information according to well-defined rules,
01429   returning a new string as the result. The Controller simply
01430   sends this string to the browser as (X)HTML text where it gets 
01431   handled as usual.
01432 </p>
01433 
01434 <h2>Database (Bean or Model) Objects</h2>
01435 
01436 <p>
01437   The JWAA demo uses a single persistent object,
01438   <a idref="DemoAccountBean">DemoAccountBean</a>, which manages account
01439   information in a single table, Account, in the
01440   JWAA database.  Each row manages the name and address
01441   information of a specific user. This table is populated by
01442   the login/registration process and modifed thereafter 
01443   by the account update service.  
01444 </p>
01445 
01446 </page>
01447 
01448 <page id="MODELS" name="Models" requiresRole="none"
01449   title="Models are an application's persistent memory" >
01450 
01451 <p>
01452   Model (aka "Bean") classes manage an application's data 
01453   as database tables. The demo's model class is <a
01454     idref="DemoAccountBean">DemoAccountBean</a>.  
01455   <i>Fields are to models as atoms are to molecules.</i>. This 
01456   means that models are not defined in terms of raw Java types 
01457   such as Strings. Rather the models' instance variables and method
01458   arguments are declared in terms of objects that abide by the
01459   <a idref="Validatable">Validatable</a> interface. Since Validatable objects are
01460   typically implemented as subclasses of <a idref="GenericField">GenericField</a>, 
01461   they are called <i>Field</i> classes.
01462 </p>
01463 
01464 </page>
01465 
01466 <page id="FIELDS" name="Fields" requiresRole="none"
01467   title="Fields are the atoms; models the molecules" >
01468 
01469   <p>
01470     Models are made of Fields not Strings. Strings are avoided 
01471       because:
01472   </p>
01473 
01474 <ul>
01475 
01476   <li>
01477     Fields are uniquely reusable units of reuse because they
01478     are so concrete, immediately tangible and visible to everyone 
01479     in the application's user interface
01480   </li>
01481 
01482   <li>
01483     Fields encapsulate the rules for determining whether
01484     user-provided inputs comply with the syntactical validity
01485     constraints of that field. Centralizing this logic in
01486     reusable field classes makes applications much simpler than
01487     the traditional approach of distributing this logic 
01488     throughout the application.
01489   </li>
01490 
01491   <li>
01492     Each field can enforce DBMS-specific constraints, such as 
01493     the maximum length of fixed-length fields.
01494   </li>
01495 
01496 </ul>
01497 
01498 <p>
01499   The JWAA package provides a <a idref="Validatable">Validatable</a> interface,
01500   which defines the protocol that all field implementations
01501   adhere to. It also provides an abstract <a idref="GenericField">GenericField</a> that 
01502   defines methods for subclasses to inherit.
01503 </p>
01504 
01505 <p>
01506   Typically you'd define your database to use the field
01507   lengths specified by these classes. If not you should edit the
01508   classes to match. Only U.S. address and phone numbers are
01509   provided. Revisions to support international usage would 
01510   be gratefully accepted.
01511 </p>
01512 
01513 </page>
01514 
01515 <page id="ROLES" name="Roles" requiresRole="none"
01516 title="Roles determine who can see what pages" >
01517 
01518 <p>
01519   Since each application is likely to have unique requirements
01520   for determining who is allowed to access each page, JWAA
01521   capability system is extendible. The demonstration uses the 
01522   simple three-level role system defined in 
01523   <a idref="GenericRole">GenericRole</a> and
01524   <a idref="RoleAbstraction">RoleAbstraction</a>.
01525 </p>
01526 
01527 <ul>
01528 
01529   <li>
01530     Visitor: for visitors whose identity is unknown because 
01531     they've not registered and logged on.
01532   </li>
01533 
01534   <li>
01535     Registered: for visitors that have registered and logged on.
01536   </li>
01537 
01538   <li>
01539     Admin: a privileged account permitted to access 
01540     administrative functions.
01541   </li>
01542 
01543 </ul>
01544 
01545 <p>
01546   The pages of a web application can be thought of as an outer 
01547   lobby with pages that everyone is welcome to read (logged in or not)
01548   plus an inner sanctum with pages that can only be accessed by those 
01549   who have logged in. The "portal" is the passage between them; the 
01550   guard station through which visitors pass to be identified by 
01551   the login procedure.  
01552 </p>
01553 
01554 <p>
01555   The demo application's inner sanctum consists of only three pages 
01556   to keep the demo as simple as possible: <a idref="UPDATE">UPDATE</a> 
01557   supports editing an account's registration information, 
01558   <a idref="LOGOUT">LOGOUT</a>, supports logging out, and 
01559   <a idref="ADMIN">ADMIN</a> lets administrative users view the database.
01560 </p>
01561 
01562 <p>
01563   <a idref="PORTAL">PORTAL</a> is the doorway between the two regions.
01564   If a visitor has not logged in, they browse as the account 
01565   AccountAbstraction.Null, the account for unknown visitors.
01566 </p>
01567 
01568 <p>
01569   When the visitor identifies themselves to the login
01570   procedure (in the demo, by providing a previously registered
01571   email address, but more typically, by also providing the
01572   corresponding password), <a idref="PORTAL">PORTAL</a> loads the account's
01573   persistent information from the database as an instance of
01574   <a idref="AccountAbstraction">AccountAbstraction</a> and stores a reference to this
01575   instance as a specially named session attribute. The session
01576   attribute persists as the user browses from page to page. It
01577   will only be erased by the LogoutPage, if the session times 
01578   out, or if the server itself is restarted.
01579 </p>
01580 
01581 <p>
01582   Notice that <a idref="DemoAccountBean">DemoAccountBean</a> implements the
01583   <a idref="AccountAbstraction">AccountAbstraction</a> interface, which requires that all
01584   subclasses provide a isCapable(Capability c) method. The system
01585   calls this method to determine if a given account has the 
01586   capability level in the method's argument.
01587 </p>
01588 
01589 <ul>
01590 
01591   <li>
01592     <a idref="LOOKANDFEEL">LookAndFeel</a> will refuse to show links to that
01593     page in the navigation bar. This lets the page hierarchy,
01594     which governs the navigation bar, be specified without
01595     concern for account capabilities, since the navigation bar
01596     will offer only the links that the viewer is allowed to 
01597     access.
01598   </li>
01599 
01600   <li>
01601     <a idref="GenericServlet">GenericServlet</a> redirects requests from viewers
01602     with inadequate capabilities by redirecting them to the page
01603     specified by the servlet's getRefusePage() method. This is a
01604     second line of defense to ensure that unauthorized visitors 
01605     can't bypass the protection by editing requests by hand.
01606   </li>
01607 
01608 </ul>
01609 
01610 </page>
01611 
01612 <page id="LICENSE" name="License" requiresRole="none"
01613   title="JWAA Open Source License" >
01614 
01615 <h2><a href="http://www.opensource.org">Open Source</a> Artistic License</h2>
01616 
01617 <p>
01618   This states the conditions under which JWAA may be copied,
01619     such that the Copyright Holder maintains artistic control over 
01620     its development while giving its users the right to use and 
01621     distribute the Package and the right to make reasonable modifications.
01622 </p>
01623 
01624 <h2>Definitions:</h2>
01625 
01626 <ul>
01627 
01628   <li>
01629     "Package" refers to the collection of files distributed by
01630     the Copyright Holder as the 
01631 
01632     <a idref="JWAA">Java Web Application Architecture (JWAA)</a> and 
01633     derivatives of that collection created through textual modification.
01634   </li>
01635 
01636   <li>
01637     "Copyright Holder" is Brad J. Cox, Ph.D., 9940 Bent Tree
01638 
01639         Lane, Manassas VA 20111.
01640     </li>
01641 
01642     <li>
01643       "Standard Version" refers to such a Package if it has not
01644     been modified, or has been modified in accordance with the
01645 
01646     wishes of the Copyright Holder.
01647   </li>
01648 
01649   <li>
01650     "You" is you, if you're thinking about copying or
01651 
01652         distributing this Package.
01653     </li>
01654 
01655     <li>
01656       "Reasonable copying fee" is whatever you can justify on the
01657     basis of media cost, duplication charges, time of people
01658     involved, and so on. (You will not be required to justify it to
01659     the Copyright Holder, but only to the computing community at
01660 
01661     large as a market that must bear the fee.)
01662   </li>
01663 
01664   <li>
01665     "Freely Available" means that no fee is charged for the
01666     item itself, though there may be fees involved in handling the
01667     item. It also means that recipients of the item may
01668     redistribute it under the same conditions they received
01669 
01670     it.
01671   </li>
01672 
01673 </ul>
01674 
01675 <h2>Terms</h2>
01676 
01677 <p>
01678   1. You may make and give away verbatim copies of the source
01679   form of the Standard Version of this Package without restriction,
01680   provided that you duplicate all of the original copyright notices
01681 
01682   and associated disclaimers.
01683 </p>
01684 
01685 <p>
01686   2. You may apply bug fixes, portability fixes and other
01687   modifications derived from the Public Domain or from the
01688   Copyright Holder. A Package modified in such a way shall still be
01689 
01690   considered the Standard Version.
01691 </p>
01692 
01693 <p>
01694   3. You may otherwise modify your copy of this Package in any
01695   way, provided that you insert a prominent notice in each changed
01696   file stating how and when you changed that file, and provided
01697 
01698   that you do at least ONE of the following:
01699 </p>
01700 
01701 <ul>
01702 
01703   <li>
01704     place your modifications in the Public Domain or otherwise
01705     make them Freely Available, such as by posting said
01706     modifications to Usenet or an equivalent medium, or placing the
01707     modifications on a major archive site such as ftp.uu.net, or by
01708     allowing the Copyright Holder to include your modifications in
01709 
01710     the Standard Version of the Package.
01711   </li>
01712 
01713   <li>
01714     use the modified Package only within your corporation or
01715 
01716         organization.
01717     </li>
01718 
01719     <li>
01720       rename any non-standard executables so the names do not
01721     conflict with standard executables, which must also be
01722     provided, and provide a separate manual page for each
01723     non-standard executable that clearly documents how it differs
01724 
01725     from the Standard Version.
01726   </li>
01727 
01728   <li>
01729     make other distribution arrangements with the Copyright
01730 
01731         Holder.
01732     </li>
01733 
01734 </ul>
01735 
01736 <p>
01737   4. You may distribute the programs of this Package in object
01738   code or executable form, provided that you do at least ONE of the
01739 
01740   following:
01741 </p>
01742 
01743 <ul>
01744 
01745   <li>
01746     distribute a Standard Version of the executables and
01747     library files, together with instructions (in the manual page 
01748     or equivalent) on where to get the Standard Version.
01749   </li>
01750 
01751   <li>
01752     accompany the distribution with the machine-readable source 
01753         of the Package with your modifications.
01754     </li>
01755 
01756     <li>
01757       accompany any non-standard executables with their
01758     corresponding Standard Version executables, giving the
01759     non-standard executables non-standard names, and clearly
01760     documenting the differences in manual pages (or equivalent),
01761     together with instructions on where to get the Standard 
01762     Version.
01763   </li>
01764 
01765   <li>
01766     make other distribution arrangements with the Copyright 
01767         Holder.
01768     </li>
01769 
01770 </ul>
01771 
01772 <p>
01773   5. You may charge a reasonable copying fee for any
01774   distribution of this Package. You may charge any fee you choose
01775   for support of this Package. You may not charge a fee for this
01776   Package itself. However, you may distribute this Package in
01777   aggregate with other (possibly commercial) programs as part of a
01778   larger (possibly commercial) software distribution provided that
01779 
01780   you do not advertise this Package as a product of your own.
01781 </p>
01782 
01783 <p>
01784   6. The scripts and library files supplied as input to or
01785   produced as output from the programs of this Package do not
01786   automatically fall under the copyright of this Package, but
01787   belong to whomever generated them, and may be sold commercially,
01788 
01789   and may be aggregated with this Package.
01790 </p>
01791 
01792 <p>
01793   7. C or perl subroutines supplied by you and linked into this
01794 
01795     Package shall not be considered part of this Package.
01796 </p>
01797 
01798 <p>
01799   8. The name of the Copyright Holder may not be used to endorse
01800   or promote products derived from this software without specific
01801 
01802   prior written permission.
01803 </p>
01804 
01805 <p>
01806   9.Aggregation of this Package with a commercial distribution
01807   is always permitted provided that the use of this Package is
01808   embedded; that is, when no overt attempt is made to make this
01809   Package's interfaces visible to the end user of the commercial
01810   distribution. Such use shall not be construed as a distribution
01811 
01812   of this Package.
01813 </p>
01814 
01815 <p>
01816   10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS
01817   OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
01818   WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR 
01819   PURPOSE.
01820 </p>
01821 </page>
01822 
01823 <page id="SOURCE" name="Source" requiresRole="none"
01824   title="JWAA Source Browser">
01825 
01826   <p>
01827     These links lead to documentation for configuration files and 
01828     Java classes as generated by <a idref="Doxygen">doxygen</a>.
01829   </p>
01830 
01831 <dl>
01832 
01833 <dt>Configuration Files (jwaa/root/jwaa)</dt> 
01834 
01835 <dd>#foreach($f in ["application.xml", "innerPages.xml", "outerPages.xml", "velocity.macros"])
01836 <a href="$self.link($f)">$f</a>
01837 #end
01838 </dd>
01839 
01840 <dt>Core (edu.virtualschool.jwaa) </dt> 
01841 
01842 <dd>#foreach($f in ["Config", "Fault", "GenericIdentifiable",
01843   "GenericLookAndFeel", "GenericPage", "GenericAccount", "GenericServlet",
01844   "GenericURI", "IgnorableFault", "Image", "IntervalTimer", "IOFault",
01845   "MetaPage", "AccountAbstraction", "RoleAbstraction", "Role", "RuntimeFault", "ServletFault", "StreamUtil", "StringUtil", "TimeUtil", "TreeNode", "UnixUtil", "UserFault", "Visitor"])
01846 <a href="$self.link($f)">$f</a>
01847 #end
01848 </dd>
01849 
01850 <dt>XML (edu.virtualschool.jwaa.xml)</dt> 
01851 
01852 <dd>#foreach($f in [ "ApplicationElement", "FormElement", 
01853   "FileNotFoundFault", "IOFault",
01854   "PageElement", "PagesElement",
01855   "RootElement", "PageNotFoundFault", "ValidationFault", "VelocityEngine", "XMLFault", "Controller", "JwaaServlet", "XMLUtil"])
01856 <a href="$self.link($f)">$f</a>
01857 #end
01858 </dd>
01859 
01860 <dt>DBMS (edu.virtualschool.jwaa.dbms)</dt> 
01861 
01862 <dd>#foreach($f in ["DB", "DBPool", "DBQuery", "DBUpdate", "DBUtil"])
01863 <a href="$self.link($f)">$f</a>
01864 #end
01865 </dd>
01866 
01867 <dt>Fields (edu.virtualschool.jwaa.field)</dt> 
01868 <dd>#foreach ($f in ["FileField", "CityField", "ClassField", "CommaSeparatedField", "CountryField", "DoubleField", "EmailField", "FieldUtil", "GenericField", "IdentifierField", "IDField", "IntegerField", "LongField", "NameField", "OpField", "PassField", "PathField", "PhoneField", "StreetField", "TextField", "UrlField", "USStateField", "Validatable", "YesNoField", "ZipcodeField"]) 
01869 <a href="$self.link($f)">$f</a>
01870 #end
01871 </dd>
01872 
01873 </dl>
01874 </page>
01875 
01876 <page id="INSTALLATION" name="Installation" requiresRole="none"
01877   title="Installation and Configuration Instructions" >
01878   <child idref="CONFIGURATION"/>
01879   <child idref="TROUBLESHOOTING"/>
01880 
01881 <h2>Prerequisite Software</h2>
01882 
01883   <p>
01884     We'll assume this prerequisite software is already installed
01885     and propertly configured. Each comes with its own instructions,
01886     which won't be repeated here.
01887   </p>
01888 
01889   <ol>
01890 
01891     <li>
01892       <a idref="Apache">Apache</a> (or equivalent) web server.
01893     </li>
01894 
01895     <li>
01896       <a idref="MySQL">MySQL</a>: Any recent version that supports 
01897       transactions (InnoDB) will do. Other relational databases may work 
01898       with minor changes but this has not been tested.  Be sure to 
01899       assign a root password as described in its instructions. Confirm 
01900       that it is working properly before proceeding.
01901     </li>
01902 
01903     <li>
01904       <a idref="Java">Java</a>: Download a recent version of the
01905       Java Software Development Kit (SDK). Avoid the Java Runtime 
01906       Environment version (JRE) which is significantly smaller but 
01907       only capable of running Java, not compiling it.
01908     </li>
01909 
01910     <li>
01911       <a idref="Jetty">Jetty</a> or <a idref="Tomcat">Tomcat</a>:
01912       Jetty is smaller and faster. Either will do.
01913     </li>
01914 
01915   </ol>
01916 
01917   <p>
01918     You will need these installed on the private computer you'll use 
01919     to test your work privately and also on the public server you'll
01920     copy your work to so others can see it.  I'll refer to the first
01921     machine as your <i>development</i> or <i>private</i> machine and 
01922     the other as your <i>deployment</i> or <i>public</i>machine.
01923   </p>
01924 
01925 <h2>The JWAA Distribution Directory Structure</h2>
01926 
01927   <p>
01928     Unpack the distribution archive in your web server's document root 
01929     directory.  If this is /var/www/html, you'd type:
01930   </p>
01931 
01932   <pre>
01933   cd /var/www/html
01934   tar zxf path/to/jwaa.tgz 
01935   </pre>
01936 
01937   <p>
01938     This will create a new directory, /var/www/html/jwaa,
01939     that will be called the <i>installation</i> directory
01940     or simply <i>jwaa</i> for brevity. This directory contains:
01941   </p>
01942 
01943   <dl>
01944 
01945   <dt>root, root/jwaa</dt>
01946 
01947   <dd>
01948     The subdirectories of the jwaa/root directory define each JWAA 
01949     application.  JWAA is intially distributed with one such 
01950     subdirectory, jwaa/root/jwaa. This defines the pages you're
01951     reading now as three XML files.  
01952     <a idref="application.xml">application.xml</a> 
01953     defines the application as a whole, 
01954     <a idref="outerPages.xml">outerPages.xml</a>
01955     defines the external pages (the pages that are accessible
01956     without logging in) and 
01957     <a idref="innerPages.xml">innerPages.xml</a> 
01958     defines the inner pages (the demo application which requires
01959     logging in via the <a idref="PORTAL">Demo</a> link at the top 
01960     right of each page.).
01961   </dd>
01962 
01963   <dd>
01964     The root directory can be moved if you want by changing the line
01965     that defines its location in WEB-INF/web.xml.
01966   </dd>
01967 
01968   <dt>WEB-INF</dt>
01969 
01970   <dd>
01971     The servlet deployment directory contains a web.xml file
01972     for the JWAA servlet and a lib directory.  The lib directory 
01973     contains jwaa.jar with jwaa's java components plus the libraries
01974     that jwaa.jar depends on. These include the latest versions of
01975     commons-collections.jar, gnu-regexp-1.1.4.jar, jaxen-core.jar, 
01976     jaxen-jdom.jar, jdom.jar, junit.jar, jwaa.jar, log4j-1.2.8.jar, 
01977     mysql-connector-java-3.0.10-stable-bin.jar, saxpath.jar,
01978     velocity-1.5-dev.jar, xerces.jar, and xml-apis.jar. All are
01979     standard packages except for velocity. The a pre-release 
01980     version is included which repairs an incompatibility between
01981     Velocity and XML entity syntax by accepting "and" as a synonym
01982     for the problematic &amp;&amp;.
01983   </dd>
01984 
01985   <dt>sql</dt>
01986 
01987   <dd>
01988     This directory contains a MySQL script that you'll use to define
01989     the JWAA database.
01990   </dd>
01991 
01992   <dt>src</dt>
01993 
01994   <dd>
01995     This directory contains the source for the Java components of the
01996     JWAA distribution
01997   </dd>
01998 
01999   <dt>index.html</dt>
02000 
02001   <dd>
02002     The JWAA home page is distributed as a conventional static html
02003     file, index.html. Confirm that this page is accessible at the url
02004     <a href="http://localhost/jwaa">http://localhost/jwaa</a>. The
02005     links inside this page will not be accessible until Apache has
02006     been configured to route them to the servlet engine and the servlet
02007     engine has been configured to route them to the JWAA servlet.
02008   </dd>
02009 
02010   <dd>
02011     Once these configuration steps have been completed, the JWAA home
02012     page will also be accessible as a dynamic page at the URL
02013     <a href="http://localhost/jwaa/xml/jwaa/OUTER">http://localhost/jwaa/xml/jwaa/OUTER</a>.
02014     The index.html file is periodically generated by browsing the dynamic
02015     URL and saving the result as index.html. This ensures that the
02016     home page is accessible even when the servlet engine is down
02017     and makes this page accessible to search engines that might be 
02018     unable to access servlet-based pages.
02019   </dd>
02020 
02021   </dl>
02022 
02023 <h2>MySQL Initialization</h2>
02024 
02025   <p>
02026     These instructions assume that MySQL has been installed by
02027     following its own instructions and is working propertly. 
02028     All that remains is defining a database for JWAA to use,
02029     defining a MySQL user with ownership rights for that
02030     database, assigning that user a secure password, and 
02031     conveying this information to JWAA by editing jwaa's
02032     application.xml file.
02033   </p>
02034 
02035   <p>
02036     The sql directory contains a sql script, initialize_jwaa_database.sql.
02037     This script initializes the jwaa database (dropping any existing one; 
02038     careful!) and creates a user, jwaa, with full permissions on that 
02039     database.  Edit the script before using it. AT THE VERY LEAST change 
02040     the password to something secret! Then run the script by typing:
02041   </p>
02042 
02043   <pre>
02044   mysql &lt;sql/initialize_jwaa_database.sql 
02045   </pre>
02046 
02047   <p>
02048     Then specify the same password in the jdbc section of 
02049     root/jwaa/application.xml. JWAA uses JDBC and should work 
02050     with any database but this has not been tested. 
02051   </p>
02052 
02053   <p>
02054     See <a href="CONFIGURATION">the configuration instructions</a>
02055     for how to configure these systems to work together properly.
02056   </p>
02057 
02058   </page>
02059 
02060   <page id="CONFIGURATION" name="Configuration" requiresRole="none"
02061     title="Configuring Apache, Servlet Engine, and JWAA" >
02062 
02063   <p>
02064     Jetty contains its own HTTP server so Apache isn't actually necessary.
02065     However many installations will prefer to let Apache's C code service 
02066     static web pages and route only the specific URLs that require dynamic 
02067     behavior to Jetty, which being written in Java, is arguably not as fast.
02068   </p>
02069 
02070   <p>
02071     Apache's world consists of an incoming stream of slash-delimited names 
02072     which Apache treats as pathnames to files within its document root 
02073     directory. If the requested file exists, Apache returns that file to 
02074     the browser, else it returns an error message. 
02075   </p>
02076 
02077   <p>
02078     This is an oversimplification because Apache is (almost) infinitely 
02079     configurable.  Our first task is to configure Apache to treat URLs 
02080     beginning with a specially desig