Author: kkolinko Date: Sun Apr 27 22:48:19 2014 New Revision: 1590513 URL: http://svn.apache.org/r1590513 Log: Improve documentation markup. This is partial backport of r1518540 from trunk.
Modified: tomcat/tc7.0.x/trunk/webapps/docs/connectors.xml tomcat/tc7.0.x/trunk/webapps/docs/default-servlet.xml tomcat/tc7.0.x/trunk/webapps/docs/deployer-howto.xml tomcat/tc7.0.x/trunk/webapps/docs/html-manager-howto.xml tomcat/tc7.0.x/trunk/webapps/docs/jasper-howto.xml tomcat/tc7.0.x/trunk/webapps/docs/jndi-datasource-examples-howto.xml Modified: tomcat/tc7.0.x/trunk/webapps/docs/connectors.xml URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/connectors.xml?rev=1590513&r1=1590512&r2=1590513&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/connectors.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/connectors.xml Sun Apr 27 22:48:19 2014 @@ -64,13 +64,12 @@ needed for any reason, an AJP connector proxied HTTP. AJP clustering is the most efficient from the Tomcat perspective. It is otherwise functionally equivalent to HTTP clustering.</p> -<p>The native connectors supported with this Tomcat release are: +<p>The native connectors supported with this Tomcat release are:</p> <ul> <li>JK 1.2.x with any of the supported servers</li> <li>mod_proxy on Apache HTTP Server 2.x (included by default in Apache HTTP Server 2.2), with AJP enabled</li> </ul> -</p> <p><b>Other native connectors supporting AJP may work, but are no longer supported.</b></p> Modified: tomcat/tc7.0.x/trunk/webapps/docs/default-servlet.xml URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/default-servlet.xml?rev=1590513&r1=1590512&r2=1590513&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/default-servlet.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/default-servlet.xml Sun Apr 27 22:48:19 2014 @@ -34,59 +34,56 @@ </section> <section anchor="what" name="What is the DefaultServlet"> +<p> The default servlet is the servlet which serves static resources as well as serves the directory listings (if directory listings are enabled). - +</p> </section> <section anchor="where" name="Where is it declared?"> +<p> It is declared globally in <i>$CATALINA_BASE/conf/web.xml</i>. By default here is it's declaration: -<source> - <servlet> - <servlet-name>default</servlet-name> - <servlet-class> +</p> +<source><![CDATA[ <servlet> + <servlet-name>default</servlet-name> + <servlet-class> org.apache.catalina.servlets.DefaultServlet - </servlet-class> - <init-param> - <param-name>debug</param-name> - <param-value>0</param-value> - </init-param> - <init-param> - <param-name>listings</param-name> - <param-value>false</param-value> - </init-param> - <load-on-startup>1</load-on-startup> - </servlet> + </servlet-class> + <init-param> + <param-name>debug</param-name> + <param-value>0</param-value> + </init-param> + <init-param> + <param-name>listings</param-name> + <param-value>false</param-value> + </init-param> + <load-on-startup>1</load-on-startup> + </servlet> ... - <servlet-mapping> - <servlet-name>default</servlet-name> - <url-pattern>/</url-pattern> - </servlet-mapping> - -</source> + <servlet-mapping> + <servlet-name>default</servlet-name> + <url-pattern>/</url-pattern> + </servlet-mapping>]]></source> So by default, the default servlet is loaded at webapp startup and directory listings are disabled and debugging is turned off. </section> <section anchor="change" name="What can I change?"> -The DefaultServlet allows the following initParamters: +<p> + The DefaultServlet allows the following initParamters: +</p> -<table border="1"> - <tr> - <th valign='top'>debug</th> - <td valign='top'> +<properties> + <property name="debug"> Debugging level. It is not very useful unless you are a tomcat developer. As of this writing, useful values are 0, 1, 11, 1000. [0] - </td> - </tr> - <tr> - <th valign='top'>listings</th> - <td valign='top'> + </property> + <property name="listings"> If no welcome file is present, can a directory listing be shown? value may be <b>true</b> or <b>false</b> [false] @@ -96,19 +93,13 @@ The DefaultServlet allows the following <b>WARNING:</b> Listings of directories containing many entries are expensive. Multiple requests for large directory listings can consume significant proportions of server resources. - </td> - </tr> - <tr> - <th valign='top'>readmeFile</th> - <td valign='top'> + </property> + <property name="readmeFile"> If a directory listing is presented, a readme file may also be presented with the listing. This file is inserted as is so it may contain HTML. - </td> - </tr> - <tr> - <th valign='top'>globalXsltFile</th> - <td valign='top'> + </property> + <property name="globalXsltFile"> If you wish to customize your directory listing, you can use an XSL transformation. This value is a relative file name (to either $CATALINA_BASE/conf/ or $CATALINA_HOME/conf/) which will be used @@ -116,11 +107,8 @@ The DefaultServlet allows the following per directory. See <strong>contextXsltFile</strong> and <strong>localXsltFile</strong> below. The format of the xml is shown below. - </td> - </tr> - <tr> - <th valign='top'>contextXsltFile</th> - <td valign='top'> + </property> + <property name="contextXsltFile"> You may also customize your directory listing by context by configuring <code>contextXsltFile</code>. This must be a context relative path (e.g.: <code>/path/to/context.xslt</code>) to a file with @@ -129,11 +117,8 @@ The DefaultServlet allows the following not exist, then <code>globalXsltFile</code> will be used. If <code>globalXsltFile</code> does not exist, then the default directory listing will be shown. - </td> - </tr> - <tr> - <th valign='top'>localXsltFile</th> - <td valign='top'> + </property> + <property name="localXsltFile"> You may also customize your directory listing by directory by configuring <code>localXsltFile</code>. This must be a file in the directory where the listing will take place to with a @@ -145,53 +130,33 @@ The DefaultServlet allows the following <code>globalXsltFile</code> will be used. If <code>globalXsltFile</code> does not exist, then the default directory listing will be shown. - </td> - </tr> - <tr> - <th valign='top'>input</th> - <td valign='top'> + </property> + <property name="input"> Input buffer size (in bytes) when reading resources to be served. [2048] - </td> - </tr> - <tr> - <th valign='top'>output</th> - <td valign='top'> + </property> + <property name="output"> Output buffer size (in bytes) when writing resources to be served. [2048] - </td> - </tr> - <tr> - <th valign='top'>readonly</th> - <td valign='top'> + </property> + <property name="readonly"> Is this context "read only", so HTTP commands like PUT and DELETE are rejected? [true] - </td> - </tr> - <tr> - <th valign='top'>fileEncoding</th> - <td valign='top'> + </property> + <property name="fileEncoding"> File encoding to be used when reading static resources. [platform default] - </td> - </tr> - <tr> - <th valign='top'>sendfileSize</th> - <td valign='top'> + </property> + <property name="sendfileSize"> If the connector used supports sendfile, this represents the minimal file size in KB for which sendfile will be used. Use a negative value to always disable sendfile. [48] - </td> - </tr> - <tr> - <th valign='top'>useAcceptRanges</th> - <td valign='top'> + </property> + <property name="useAcceptRanges"> If true, the Accept-Ranges header will be set when appropriate for the response. [true] - </td> - </tr> - -</table> + </property> +</properties> </section> <section anchor="dir" name="How do I customize directory listings?"> @@ -213,102 +178,101 @@ behaviors takes place. <p> Format: -<source> - <listing> - <entries> - <entry type='file|dir' urlPath='aPath' size='###' date='gmt date'> +</p> +<source><![CDATA[ <listing> + <entries> + <entry type='file|dir' urlPath='aPath' size='###' date='gmt date'> fileName1 - </entry> - <entry type='file|dir' urlPath='aPath' size='###' date='gmt date'> + </entry> + <entry type='file|dir' urlPath='aPath' size='###' date='gmt date'> fileName2 - </entry> + </entry> ... - </entries> - <readme></readme> - </listing> -</source> + </entries> + <readme></readme> + </listing>]]></source> <ul> <li>size will be missing if <code>type='dir'</code></li> <li>Readme is a CDATA entry</li> </ul> + +<p> + The following is a sample xsl file which mimics the default tomcat behavior: </p> -The following is a sample xsl file which mimics the default tomcat behavior: -<source> -<?xml version="1.0"?> - -<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" - version="1.0"> - - <xsl:output method="xhtml" encoding="iso-8859-1" indent="no"/> - - <xsl:template match="listing"> - <html> - <head> - <title> +<source><![CDATA[<?xml version="1.0" encoding="UTF-8"?> + +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + version="3.0"> + + <xsl:output method="html" html-version="5.0" + encoding="UTF-8" indent="no" + doctype-system="about:legacy-compat"/> + + <xsl:template match="listing"> + <html> + <head> + <title> Sample Directory Listing For - <xsl:value-of select="@directory"/> - </title> - <style> - h1{color : white;background-color : #0086b2;} - h3{color : white;background-color : #0086b2;} - body{font-family : sans-serif,Arial,Tahoma; + <xsl:value-of select="@directory"/> + </title> + <style> + h1 {color : white;background-color : #0086b2;} + h3 {color : white;background-color : #0086b2;} + body {font-family : sans-serif,Arial,Tahoma; color : black;background-color : white;} - b{color : white;background-color : #0086b2;} - a{color : black;} HR{color : #0086b2;} - </style> - </head> - <body> - <h1>Sample Directory Listing For - <xsl:value-of select="@directory"/> - </h1> - <hr size="1" /> - <table cellspacing="0" - width="100%" - cellpadding="5" - align="center"> - <tr> - <th align="left">Filename</th> - <th align="center">Size</th> - <th align="right">Last Modified</th> - </tr> - <xsl:apply-templates select="entries"/> - </table> - <xsl:apply-templates select="readme"/> - <hr size="1" /> - <h3>Apache Tomcat/7.0</h3> - </body> - </html> - </xsl:template> - - - <xsl:template match="entries"> - <xsl:apply-templates select="entry"/> - </xsl:template> - - <xsl:template match="readme"> - <hr size="1" /> - <pre><xsl:apply-templates/></pre> - </xsl:template> - - <xsl:template match="entry"> - <tr> - <td align="left"> - <xsl:variable name="urlPath" select="@urlPath"/> - <a href="{$urlPath}"> - <tt><xsl:apply-templates/></tt> - </a> - </td> - <td align="right"> - <tt><xsl:value-of select="@size"/></tt> - </td> - <td align="right"> - <tt><xsl:value-of select="@date"/></tt> - </td> - </tr> - </xsl:template> + b {color : white;background-color : #0086b2;} + a {color : black;} HR{color : #0086b2;} + table td { padding: 5px; } + </style> + </head> + <body> + <h1>Sample Directory Listing For + <xsl:value-of select="@directory"/> + </h1> + <hr style="height: 1px;" /> + <table style="width: 100%;"> + <tr> + <th style="text-align: left;">Filename</th> + <th style="text-align: center;">Size</th> + <th style="text-align: right;">Last Modified</th> + </tr> + <xsl:apply-templates select="entries"/> + </table> + <xsl:apply-templates select="readme"/> + <hr style="height: 1px;" /> + <h3>Apache Tomcat/8.0</h3> + </body> + </html> + </xsl:template> + + + <xsl:template match="entries"> + <xsl:apply-templates select="entry"/> + </xsl:template> + + <xsl:template match="readme"> + <hr style="height: 1px;" /> + <pre><xsl:apply-templates/></pre> + </xsl:template> + + <xsl:template match="entry"> + <tr> + <td style="text-align: left;"> + <xsl:variable name="urlPath" select="@urlPath"/> + <a href="{$urlPath}"> + <pre><xsl:apply-templates/></pre> + </a> + </td> + <td style="text-align: right;"> + <pre><xsl:value-of select="@size"/></pre> + </td> + <td style="text-align: right;"> + <pre><xsl:value-of select="@date"/></pre> + </td> + </tr> + </xsl:template> -</xsl:stylesheet> -</source> +</xsl:stylesheet>]]></source> </section> Modified: tomcat/tc7.0.x/trunk/webapps/docs/deployer-howto.xml URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/deployer-howto.xml?rev=1590513&r1=1590512&r2=1590513&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/deployer-howto.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/deployer-howto.xml Sun Apr 27 22:48:19 2014 @@ -41,7 +41,8 @@ </p> <p> Web application deployment may be accomplished in a number of ways - within the Tomcat server.</p> + within the Tomcat server. + </p> <ul> <li>Statically; the web application is setup before Tomcat is started</li> <li> Modified: tomcat/tc7.0.x/trunk/webapps/docs/html-manager-howto.xml URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/html-manager-howto.xml?rev=1590513&r1=1590512&r2=1590513&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/html-manager-howto.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/html-manager-howto.xml Sun Apr 27 22:48:19 2014 @@ -125,33 +125,29 @@ stop the web application that relies on users continuously encounter database exceptions.</p> <p>If this command succeeds, you will see a Message like this:</p> -<source> -OK - Started application at context path /examples -</source> +<source>OK - Started application at context path /examples</source> <p>Otherwise, the Message will start with <code>FAIL</code> and include an error message. Possible causes for problems include:</p> <ul> <li><em>Encountered exception</em> - <blockquote> <p>An exception was encountered trying to start the web application. Check the Tomcat logs for the details.</p> - </blockquote></li> + </li> <li><em>Invalid context path was specified</em> - <blockquote> <p>The context path must start with a slash character, unless you are referencing the ROOT web application -- in which case the context path must be a zero-length string.</p> - </blockquote></li> + </li> <li><em>No context exists for path /foo</em> - <blockquote> <p>There is no deployed application on the context path that you specified.</p> - </blockquote></li> + </li> <li><em>No context path was specified</em> - <blockquote> + <p> The <code>path</code> parameter is required. - </blockquote></li> + </p> +</li> </ul> </subsection> @@ -164,33 +160,29 @@ stopped will see an HTTP error 404, and "stopped" on a list applications command.</p> <p>If this command succeeds, you will see a Message like this:</p> -<source> -OK - Stopped application at context path /examples -</source> +<source>OK - Stopped application at context path /examples</source> <p>Otherwise, the Message will start with <code>FAIL</code> and include an error message. Possible causes for problems include:</p> <ul> <li><em>Encountered exception</em> - <blockquote> <p>An exception was encountered trying to stop the web application. Check the Tomcat logs for the details.</p> - </blockquote></li> + </li> <li><em>Invalid context path was specified</em> - <blockquote> <p>The context path must start with a slash character, unless you are referencing the ROOT web application -- in which case the context path must be a zero-length string.</p> - </blockquote></li> + </li> <li><em>No context exists for path /foo</em> - <blockquote> <p>There is no deployed application on the context path that you specified.</p> - </blockquote></li> + </li> <li><em>No context path was specified</em> - <blockquote> + <p> The <code>path</code> parameter is required. - </blockquote></li> + </p> +</li> </ul> </subsection> @@ -219,42 +211,37 @@ OK - Reloaded application at context pat error message. Possible causes for problems include:</p> <ul> <li><em>Encountered exception</em> - <blockquote> <p>An exception was encountered trying to restart the web application. Check the Tomcat logs for the details.</p> - </blockquote></li> + </li> <li><em>Invalid context path was specified</em> - <blockquote> <p>The context path must start with a slash character, unless you are referencing the ROOT web application -- in which case the context path must be a zero-length string.</p> - </blockquote></li> + </li> <li><em>No context exists for path /foo</em> - <blockquote> <p>There is no deployed application on the context path that you specified.</p> - </blockquote></li> + </li> <li><em>No context path was specified</em> - <blockquote> - The <code>path</code> parameter is required. - </blockquote></li> + <p>The <code>path</code> parameter is required.</p> + </li> <li><em>Reload not supported on WAR deployed at path /foo</em> - <blockquote> - Currently, application reloading (to pick up changes to the classes or + <p>Currently, application reloading (to pick up changes to the classes or <code>web.xml</code> file) is not supported when a web application is installed directly from a WAR file, which happens when the host is configured to not unpack WAR files. As it only works when the web application is installed from an unpacked directory, if you are using a WAR file, you should <code>undeploy</code> and then <code>deploy</code> - the application again to pick up your changes. - </blockquote></li> + the application again to pick up your changes.</p> + </li> </ul> </subsection> <subsection name="Undeploy"> -<p><strong><font color="red">WARNING</font> - This command will delete the +<p><strong><span style="color: red;">WARNING</span> - This command will delete the contents of the web application directory and/or ".war" file if it exists within the <code>appBase</code> directory (typically "webapps") for this virtual host </strong>. The web application temporary work directory is also deleted. If @@ -268,33 +255,27 @@ reuse later). This command is the logic in the HTML manager.</p> <p>If this command succeeds, you will see a Message like this:</p> -<source> -OK - Undeployed application at context path /examples -</source> +<source>OK - Undeployed application at context path /examples</source> <p>Otherwise, the Message will start with <code>FAIL</code> and include an error message. Possible causes for problems include:</p> <ul> <li><em>Encountered exception</em> - <blockquote> <p>An exception was encountered trying to undeploy the web application. Check the Tomcat logs for the details.</p> - </blockquote></li> + </li> <li><em>Invalid context path was specified</em> - <blockquote> <p>The context path must start with a slash character, unless you are referencing the ROOT web application -- in which case the context path must be a zero-length string.</p> - </blockquote></li> + </li> <li><em>No context exists for path /foo</em> - <blockquote> <p>There is no deployed application on the context path that you specified.</p> - </blockquote></li> + </li> <li><em>No context path was specified</em> - <blockquote> The <code>path</code> parameter is required. - </blockquote></li> + </li> </ul> </subsection> @@ -319,7 +300,7 @@ This command is the logical opposite of <p>There are a number of different ways the deploy command can be used.</p> -<h3>Deploy a Directory or WAR by URL</h3> +<h5>Deploy a Directory or WAR by URL</h5> <p>Install a web application directory or ".war" file located on the Tomcat server. If no <i>Context Path</i> is specified, the directory name or the @@ -344,12 +325,10 @@ Tomcat server (running on Unix) is deplo context named <code>/bar</code>. Notice that there is no <code>path</code> parameter so the context path defaults to the name of the web application archive file without the ".war" extension.</p> -<source> -WAR or Directory URL: jar:file:/path/to/bar.war!/ -</source> +<source>WAR or Directory URL: jar:file:/path/to/bar.war!/</source> -<h3>Deploy a Directory or War from the Host appBase</h3> +<h5>Deploy a Directory or War from the Host appBase</h5> <p>Install a web application directory or ".war" file located in your Host appBase directory. If no <i>Context Path</i> is specified the directory name @@ -360,21 +339,17 @@ or the war file name without the ".war" deployed as the web application context named <code>/foo</code>. Notice that there is no <code>path</code> parameter so the context path defaults to the name of the web application directory.</p> -<source> -WAR or Directory URL: foo -</source> +<source>WAR or Directory URL: foo</source> <p>In this example the ".war" file <code>bar.war</code> located in your Host appBase directory on the Tomcat server is deployed as the web application context named <code>/bartoo</code>.</p> -<source> -Context Path: /bartoo -WAR or Directory URL: bar.war -</source> +<source>Context Path: /bartoo +WAR or Directory URL: bar.war</source> -<h3>Deploy using a Context configuration ".xml" file</h3> +<h5>Deploy using a Context configuration ".xml" file</h5> <p>If the Host deployXML flag is set to true, you can install a web application using a Context configuration ".xml" file and an optional @@ -386,10 +361,8 @@ configuration file.</p> web application Context just as if it were configured in your Tomcat <code>server.xml</code> configuration file. Here is an example for Tomcat running on Windows:</p> -<source> -<Context path="/foobar" docBase="C:\path\to\application\foobar"> -</Context> -</source> +<source><![CDATA[<Context path="/foobar" docBase="C:\path\to\application\foobar"> +</Context>]]></source> <p>Use of the <i>WAR or Directory URL</i> is optional. When used @@ -398,18 +371,14 @@ docBase configured in the context config <p>Here is an example of installing an application using a Context configuration ".xml" file for Tomcat running on Windows.</p> -<source> -XML Configuration file URL: file:C:/path/to/context.xml -</source> +<source>XML Configuration file URL: file:C:/path/to/context.xml</source> <p>Here is an example of installing an application using a Context configuration ".xml" file and a web application ".war" file located on the server (Tomcat running on Unix).</p> -<source> -XML Configuration file URL: file:/path/to/context.xml -WAR or Directory URL: jar:file:/path/to/bar.war!/ -</source> +<source>XML Configuration file URL: file:/path/to/context.xml +WAR or Directory URL: jar:file:/path/to/bar.war!/</source> </subsection> @@ -430,26 +399,22 @@ including a Context configuration XML fi <p>Upload of a WAR file could fail for the following reasons:</p> <ul> <li><em>File uploaded must be a .war</em> - <blockquote> <p>The upload install will only accept files which have the filename extension of ".war".</p> - </blockquote></li> + </li> <li><em>War file already exists on server</em> - <blockquote> <p>If a war file of the same name already exists in your Host's appBase the upload will fail. Either undeploy the existing war file from your Host's appBase or upload the new war file using a different name.</p> - </blockquote></li> + </li> <li><em>File upload failed, no file</em> - <blockquote> <p>The file upload failed, no file was received by the server.</p> - </blockquote></li> + </li> <li><em>Install Upload Failed, Exception:</em> - <blockquote> <p>The war file upload or install failed with a Java Exception. The exception message will be listed.</p> - </blockquote></li> + </li> </ul> </subsection> @@ -477,62 +442,54 @@ files located outside of their Host appB <p>If deployment and startup is successful, you will receive a Message like this:</p> -<source> -OK - Deployed application at context path /foo -</source> +<source>OK - Deployed application at context path /foo</source> <p>Otherwise, the Message will start with <code>FAIL</code> and include an error message. Possible causes for problems include:</p> <ul> <li><em>Application already exists at path /foo</em> - <blockquote> <p>The context paths for all currently running web applications must be unique. Therefore, you must either undeploy the existing web application using this context path, or choose a different context path for the new one.</p> - </blockquote></li> + </li> <li><em>Document base does not exist or is not a readable directory</em> - <blockquote> <p>The URL specified by the <i>WAR or Directory URL:</i> field must identify a directory on this server that contains the "unpacked" version of a web application, or the absolute URL of a web application archive (WAR) file that contains this application. Correct the value entered for the <i>WAR or Directory URL:</i> field.</p> - </blockquote></li> + </li> <li><em>Encountered exception</em> - <blockquote> <p>An exception was encountered trying to start the new web application. Check the Tomcat logs for the details, but likely explanations include problems parsing your <code>/WEB-INF/web.xml</code> file, or missing classes encountered when initializing application event listeners and filters.</p> - </blockquote></li> + </li> <li><em>Invalid application URL was specified</em> - <blockquote> <p>The URL for the <i>WAR or Directory URL:</i> field that you specified was not valid. Such URLs must start with <code>file:</code>, and URLs for a WAR file must end in ".war".</p> - </blockquote></li> + </li> <li><em>Invalid context path was specified</em> - <blockquote> <p>The context path must start with a slash character, unless you are referencing the ROOT web application -- in which case the context path must be a "/" string.</p> - </blockquote></li> + </li> <li><em>Context path must match the directory or WAR file name:</em> - <blockquote> - If the application war or directory is deployed in your Host appBase + <p>If the application war or directory is deployed in your Host appBase directory and either the Host is configured with autoDeploy=true the Context path must match the directory name or war file name without the ".war" - extension. - </blockquote></li> + extension.</p> + </li> <li><em>Only web applications in the Host web application directory can be deployed</em> - <blockquote> + <p> If the Host deployXML flag is set to false this error will happen if an attempt is made to install a web application directory or ".war" file outside of the Host appBase directory. - </blockquote></li> + </p></li> </ul> </subsection> Modified: tomcat/tc7.0.x/trunk/webapps/docs/jasper-howto.xml URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/jasper-howto.xml?rev=1590513&r1=1590512&r2=1590513&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/jasper-howto.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/jasper-howto.xml Sun Apr 27 22:48:19 2014 @@ -42,7 +42,7 @@ specification.</p> <p>Jasper 2 has been redesigned to significantly improve performance over the original Jasper. In addition to general code improvements the following -changes were made: +changes were made:</p> <ul> <li><strong>JSP Custom Tag Pooling</strong> - The java objects instantiated for JSP Custom Tags can now be pooled and reused. This significantly boosts @@ -61,7 +61,7 @@ Eclipse JDT Java compiler is now used to compilation. This compiler loads source dependencies from the container classloader. Ant and javac can still be used.</li> </ul> -</p> + <p>Jasper is implemented using the servlet class <code>org.apache.jasper.servlet.JspServlet</code>.</p> @@ -71,13 +71,13 @@ classloader. Ant and javac can still be <section name="Configuration"> <p>By default Jasper is configured for use when doing web application -development. See the section <a href="#Production Configuration"> +development. See the section <a href="#Production_Configuration"> Production Configuration</a> for information on configuring Jasper for use on a production Tomcat server.</p> <p>The servlet which implements Jasper is configured using init parameters in your global <code>$CATALINA_BASE/conf/web.xml</code>. - +</p> <ul> <li><strong>checkInterval</strong> - If development is false and checkInterval is greater than zero, background compiles are enabled. checkInterval is the time @@ -198,7 +198,7 @@ actions or directives be trimmed ?, defa header is added by generated servlet. <code>true</code> or <code>false</code>, default <code>false</code>.</li> </ul> -</p> + <p>The Java compiler from Eclipse JDT in included as the default compiler. It is an advanced Java compiler which will load all dependencies from the Tomcat class @@ -222,12 +222,12 @@ bug 6294277</a>, may cause a <code>java.lang.InternalError: name is too long to represent</code> exception when compiling very large JSPs. If this is observed then it may be worked around by using one of the following: +</p> <ul> <li>reduce the size of the JSP</li> <li>disable SMAP generation and JSR-045 support by setting <code>suppressSmap</code> to <code>true</code>.</li> </ul> -</p> </section> @@ -239,7 +239,7 @@ jsp-property-group feature) or practical Jasper servlet becomes critical.</p> <p>When using Jasper 2 in a production Tomcat server you should consider making -the following changes from the default configuration. +the following changes from the default configuration.</p> <ul> <li><strong>development</strong> - To disable on access checks for JSP pages compilation set this to <code>false</code>.</li> @@ -251,7 +251,6 @@ this to a high value will improve perfor <li><strong>trimSpaces</strong> - To remove useless bytes from the response, set this to <code>true</code>.</li> </ul> -</p> </section> @@ -264,73 +263,68 @@ Use the script given below (a similar sc download) to precompile a webapp: </p> -<p> -<source> -<project name="Webapp Precompilation" default="all" basedir="."> +<source><![CDATA[<project name="Webapp Precompilation" default="all" basedir="."> - <import file="${tomcat.home}/bin/catalina-tasks.xml"/> + <import file="${tomcat.home}/bin/catalina-tasks.xml"/> - <target name="jspc"> + <target name="jspc"> - <jasper + <jasper validateXml="false" uriroot="${webapp.path}" webXmlFragment="${webapp.path}/WEB-INF/generated_web.xml" - outputDir="${webapp.path}/WEB-INF/src" /> + outputDir="${webapp.path}/WEB-INF/src" /> - </target> + </target> - <target name="compile"> + <target name="compile"> - <mkdir dir="${webapp.path}/WEB-INF/classes"/> - <mkdir dir="${webapp.path}/WEB-INF/lib"/> + <mkdir dir="${webapp.path}/WEB-INF/classes"/> + <mkdir dir="${webapp.path}/WEB-INF/lib"/> - <javac destdir="${webapp.path}/WEB-INF/classes" + <javac destdir="${webapp.path}/WEB-INF/classes" optimize="off" debug="on" failonerror="false" srcdir="${webapp.path}/WEB-INF/src" - excludes="**/*.smap"> - <classpath> - <pathelement location="${webapp.path}/WEB-INF/classes"/> - <fileset dir="${webapp.path}/WEB-INF/lib"> - <include name="*.jar"/> - </fileset> - <pathelement location="${tomcat.home}/lib"/> - <fileset dir="${tomcat.home}/lib"> - <include name="*.jar"/> - </fileset> - <fileset dir="${tomcat.home}/bin"> - <include name="*.jar"/> - </fileset> - </classpath> - <include name="**" /> - <exclude name="tags/**" /> - </javac> - - </target> - - <target name="all" depends="jspc,compile"> - </target> - - <target name="cleanup"> - <delete> - <fileset dir="${webapp.path}/WEB-INF/src"/> - <fileset dir="${webapp.path}/WEB-INF/classes/org/apache/jsp"/> - </delete> - </target> + excludes="**/*.smap"> + <classpath> + <pathelement location="${webapp.path}/WEB-INF/classes"/> + <fileset dir="${webapp.path}/WEB-INF/lib"> + <include name="*.jar"/> + </fileset> + <pathelement location="${tomcat.home}/lib"/> + <fileset dir="${tomcat.home}/lib"> + <include name="*.jar"/> + </fileset> + <fileset dir="${tomcat.home}/bin"> + <include name="*.jar"/> + </fileset> + </classpath> + <include name="**" /> + <exclude name="tags/**" /> + </javac> + + </target> + + <target name="all" depends="jspc,compile"> + </target> + + <target name="cleanup"> + <delete> + <fileset dir="${webapp.path}/WEB-INF/src"/> + <fileset dir="${webapp.path}/WEB-INF/classes/org/apache/jsp"/> + </delete> + </target> -</project> -</source> -</p> +</project>]]></source> <p> The following command line can be used to run the script (replacing the tokens with the Tomcat base path and the path to the webapp -which should be precompiled):<br/> -<source> -$ANT_HOME/bin/ant -Dtomcat.home=<$TOMCAT_HOME> -Dwebapp.path=<$WEBAPP_PATH> -</source> +which should be precompiled): </p> +<source>$ANT_HOME/bin/ant -Dtomcat.home=<$TOMCAT_HOME> -Dwebapp.path=<$WEBAPP_PATH></source> + <p> Then, the declarations and mappings for the servlets which were generated @@ -366,7 +360,7 @@ and the compile jsp servlet classes at <code>${webapp.path}/WEB-INF/classes/org/apache/jsp</code>. </p> -<p><strong>Hints:</strong> +<p><strong>Hints:</strong></p> <ul> <li> When you switch to another Tomcat release, then regenerate and recompile your jsp's with the new Tomcat version.</li> @@ -377,7 +371,6 @@ and limit the buffering with that changing from the defaults may affect performance, but it will vary depending on the application.</li> </ul> -</p> </section> <section name="Optimisation"> Modified: tomcat/tc7.0.x/trunk/webapps/docs/jndi-datasource-examples-howto.xml URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/jndi-datasource-examples-howto.xml?rev=1590513&r1=1590512&r2=1590513&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/jndi-datasource-examples-howto.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/jndi-datasource-examples-howto.xml Sun Apr 27 22:48:19 2014 @@ -196,7 +196,7 @@ The default is <code>false</code>. <subsection name="MySQL DBCP Example"> -<h3>0. Introduction</h3> +<h5>0. Introduction</h5> <p>Versions of <a href="http://www.mysql.com/products/mysql/index.html">MySQL</a> and JDBC drivers that have been reported to work: </p> @@ -208,7 +208,7 @@ drivers that have been reported to work: <p>Before you proceed, don't forget to copy the JDBC Driver's jar into <code>$CATALINA_HOME/lib</code>.</p> -<h3>1. MySQL configuration</h3> +<h5>1. MySQL configuration</h5> <p> Ensure that you follow these instructions as variations can cause problems. </p> @@ -217,16 +217,14 @@ Ensure that you follow these instruction Your MySQL user <strong>must</strong> have a password assigned. The driver will fail if you try to connect with an empty password. </p> -<source> -mysql> GRANT ALL PRIVILEGES ON *.* TO javauser@localhost - -> IDENTIFIED BY 'javadude' WITH GRANT OPTION; -mysql> create database javatest; -mysql> use javatest; -mysql> create table testdata ( - -> id int not null auto_increment primary key, - -> foo varchar(25), - -> bar int); -</source> +<source><![CDATA[mysql> GRANT ALL PRIVILEGES ON *.* TO javauser@localhost + -> IDENTIFIED BY 'javadude' WITH GRANT OPTION; +mysql> create database javatest; +mysql> use javatest; +mysql> create table testdata ( + -> id int not null auto_increment primary key, + -> foo varchar(25), + -> bar int);]]></source> <blockquote> <strong>Note:</strong> the above user should be removed once testing is complete! @@ -234,8 +232,7 @@ complete! <p>Next insert some test data into the testdata table. </p> -<source> -mysql> insert into testdata values(null, 'hello', 12345); +<source><![CDATA[mysql> insert into testdata values(null, 'hello', 12345); Query OK, 1 row affected (0.00 sec) mysql> select * from testdata; @@ -246,95 +243,87 @@ mysql> select * from testdata; +----+-------+-------+ 1 row in set (0.00 sec) -mysql> -</source> +mysql>]]></source> -<h3>2. Context configuration</h3> +<h5>2. Context configuration</h5> <p>Configure the JNDI DataSource in Tomcat by adding a declaration for your resource to your <a href="config/context.html">Context</a>.</p> <p>For example:</p> -<source> -<Context> +<source><![CDATA[<Context> - <!-- maxActive: Maximum number of database connections in pool. Make sure you + <!-- maxActive: Maximum number of database connections in pool. Make sure you configure your mysqld max_connections large enough to handle all of your db connections. Set to -1 for no limit. - --> + --> - <!-- maxIdle: Maximum number of idle database connections to retain in pool. + <!-- maxIdle: Maximum number of idle database connections to retain in pool. Set to -1 for no limit. See also the DBCP documentation on this and the minEvictableIdleTimeMillis configuration parameter. - --> + --> - <!-- maxWait: Maximum time to wait for a database connection to become available + <!-- maxWait: Maximum time to wait for a database connection to become available in ms, in this example 10 seconds. An Exception is thrown if this timeout is exceeded. Set to -1 to wait indefinitely. - --> + --> - <!-- username and password: MySQL username and password for database connections --> + <!-- username and password: MySQL username and password for database connections --> - <!-- driverClassName: Class name for the old mm.mysql JDBC driver is + <!-- driverClassName: Class name for the old mm.mysql JDBC driver is org.gjt.mm.mysql.Driver - we recommend using Connector/J though. Class name for the official MySQL Connector/J driver is com.mysql.jdbc.Driver. - --> + --> - <!-- url: The JDBC connection url for connecting to your MySQL database. - --> + <!-- url: The JDBC connection url for connecting to your MySQL database. + --> - <Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource" + <Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="javauser" password="javadude" driverClassName="com.mysql.jdbc.Driver" - url="jdbc:mysql://localhost:3306/javatest"/> + url="jdbc:mysql://localhost:3306/javatest"/> -</Context> -</source> +</Context>]]></source> -<h3>3. web.xml configuration</h3> +<h5>3. web.xml configuration</h5> <p>Now create a <code>WEB-INF/web.xml</code> for this test application.</p> -<source> -<web-app xmlns="http://java.sun.com/xml/ns/j2ee" +<source><![CDATA[<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" - version="2.4"> - <description>MySQL Test App</description> - <resource-ref> - <description>DB Connection</description> - <res-ref-name>jdbc/TestDB</res-ref-name> - <res-type>javax.sql.DataSource</res-type> - <res-auth>Container</res-auth> - </resource-ref> -</web-app> -</source> - -<h3>4. Test code</h3> -<p>Now create a simple <code>test.jsp</code> page for use later. -<source> -<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %> -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + version="2.4"> + <description>MySQL Test App</description> + <resource-ref> + <description>DB Connection</description> + <res-ref-name>jdbc/TestDB</res-ref-name> + <res-type>javax.sql.DataSource</res-type> + <res-auth>Container</res-auth> + </resource-ref> +</web-app>]]></source> + +<h5>4. Test code</h5> +<p>Now create a simple <code>test.jsp</code> page for use later.</p> +<source><![CDATA[<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> -<sql:query var="rs" dataSource="jdbc/TestDB"> +<sql:query var="rs" dataSource="jdbc/TestDB"> select id, foo, bar from testdata -</sql:query> +</sql:query> -<html> - <head> - <title>DB Test</title> - </head> - <body> - - <h2>Results</h2> - -<c:forEach var="row" items="${rs.rows}"> - Foo ${row.foo}<br/> - Bar ${row.bar}<br/> -</c:forEach> - - </body> -</html> -</source> -</p> +<html> + <head> + <title>DB Test</title> + </head> + <body> + + <h2>Results</h2> + +<c:forEach var="row" items="${rs.rows}"> + Foo ${row.foo}<br/> + Bar ${row.bar}<br/> +</c:forEach> + + </body> +</html>]]></source> <p>That JSP page makes use of <a href="http://www.oracle.com/technetwork/java/index-jsp-135995.html">JSTL</a>'s @@ -356,7 +345,7 @@ your hard work.</p> </subsection> <subsection name="Oracle 8i, 9i & 10g"> -<h3>0. Introduction</h3> +<h5>0. Introduction</h5> <p>Oracle requires minimal changes from the MySQL configuration except for the usual gotchas :-)</p> @@ -373,7 +362,7 @@ that <code>oracle.jdbc.driver.OracleDriv for this driver class will be discontinued in the next major release. </p> -<h3>1. Context configuration</h3> +<h5>1. Context configuration</h5> <p>In a similar manner to the mysql config above, you will need to define your Datasource in your <a href="config/context.html">Context</a>. Here we define a Datasource called myoracle using the thin driver to connect as user scott, @@ -383,57 +372,51 @@ user scott.</p> <p>Use of the OCI driver should simply involve a changing thin to oci in the URL string. </p> -<source> -<Resource name="jdbc/myoracle" auth="Container" +<source><![CDATA[<Resource name="jdbc/myoracle" auth="Container" type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver" url="jdbc:oracle:thin:@127.0.0.1:1521:mysid" username="scott" password="tiger" maxActive="20" maxIdle="10" - maxWait="-1"/> -</source> + maxWait="-1"/>]]></source> -<h3>2. web.xml configuration</h3> +<h5>2. web.xml configuration</h5> <p>You should ensure that you respect the element ordering defined by the DTD when you create you applications web.xml file.</p> -<source> -<resource-ref> - <description>Oracle Datasource example</description> - <res-ref-name>jdbc/myoracle</res-ref-name> - <res-type>javax.sql.DataSource</res-type> - <res-auth>Container</res-auth> -</resource-ref> -</source> -<h3>3. Code example</h3> +<source><![CDATA[<resource-ref> + <description>Oracle Datasource example</description> + <res-ref-name>jdbc/myoracle</res-ref-name> + <res-type>javax.sql.DataSource</res-type> + <res-auth>Container</res-auth> +</resource-ref>]]></source> +<h5>3. Code example</h5> <p>You can use the same example application as above (asuming you create the required DB instance, tables etc.) replacing the Datasource code with something like</p> -<source> -Context initContext = new InitialContext(); +<source><![CDATA[Context initContext = new InitialContext(); Context envContext = (Context)initContext.lookup("java:/comp/env"); DataSource ds = (DataSource)envContext.lookup("jdbc/myoracle"); Connection conn = ds.getConnection(); -//etc. -</source> +//etc.]]></source> </subsection> <subsection name="PostgreSQL"> -<h3>0. Introduction</h3> +<h5>0. Introduction</h5> <p>PostgreSQL is configured in a similar manner to Oracle.</p> -<h3>1. Required files </h3> +<h5>1. Required files </h5> <p> Copy the Postgres JDBC jar to $CATALINA_HOME/lib. As with Oracle, the jars need to be in this directory in order for DBCP's Classloader to find them. This has to be done regardless of which configuration step you take next. </p> -<h3>2. Resource configuration</h3> +<h5>2. Resource configuration</h5> <p> You have two choices here: define a datasource that is shared across all Tomcat applications, or define a datasource specifically for one application. </p> -<h4>2a. Shared resource configuration</h4> +<h6>2a. Shared resource configuration</h6> <p> Use this option if you wish to define a datasource that is shared across multiple Tomcat applications, or if you just prefer defining your datasource @@ -442,13 +425,11 @@ in this file. <p><i>This author has not had success here, although others have reported so. Clarification would be appreciated here.</i></p> -<source> -<Resource name="jdbc/postgres" auth="Container" +<source><![CDATA[<Resource name="jdbc/postgres" auth="Container" type="javax.sql.DataSource" driverClassName="org.postgresql.Driver" url="jdbc:postgresql://127.0.0.1:5432/mydb" - username="myuser" password="mypasswd" maxActive="20" maxIdle="10" maxWait="-1"/> -</source> -<h4>2b. Application-specific resource configuration</h4> + username="myuser" password="mypasswd" maxActive="20" maxIdle="10" maxWait="-1"/>]]></source> +<h6>2b. Application-specific resource configuration</h6> <p> Use this option if you wish to define a datasource specific to your application, @@ -461,28 +442,24 @@ Create a resource definition for your <a The Context element should look something like the following. </p> -<source> -<Context> +<source><![CDATA[<Context> -<Resource name="jdbc/postgres" auth="Container" +<Resource name="jdbc/postgres" auth="Container" type="javax.sql.DataSource" driverClassName="org.postgresql.Driver" url="jdbc:postgresql://127.0.0.1:5432/mydb" username="myuser" password="mypasswd" maxActive="20" maxIdle="10" -maxWait="-1"/> -</Context> -</source> - -<h3>3. web.xml configuration</h3> -<source> -<resource-ref> - <description>postgreSQL Datasource example</description> - <res-ref-name>jdbc/postgres</res-ref-name> - <res-type>javax.sql.DataSource</res-type> - <res-auth>Container</res-auth> -</resource-ref> -</source> +maxWait="-1"/> +</Context>]]></source> -<h4>4. Accessing the datasource</h4> +<h5>3. web.xml configuration</h5> +<source><![CDATA[<resource-ref> + <description>postgreSQL Datasource example</description> + <res-ref-name>jdbc/postgres</res-ref-name> + <res-type>javax.sql.DataSource</res-type> + <res-auth>Container</res-auth> +</resource-ref>]]></source> + +<h5>4. Accessing the datasource</h5> <p> When accessing the datasource programmatically, remember to prepend <code>java:/comp/env</code> to your JNDI lookup, as in the following snippet of @@ -490,8 +467,7 @@ code. Note also that "jdbc/postgres" can you change it in the above resource definition file as well. </p> -<source> -InitialContext cxt = new InitialContext(); +<source><![CDATA[InitialContext cxt = new InitialContext(); if ( cxt == null ) { throw new Exception("Uh oh -- no context!"); } @@ -500,8 +476,7 @@ DataSource ds = (DataSource) cxt.lookup( if ( ds == null ) { throw new Exception("Data source not found!"); -} -</source> +}]]></source> </subsection> </section> @@ -540,12 +515,10 @@ using <code>System.loadLibrary("ocijdbc8 You should next create a simple test servlet or jsp that has these <strong>critical lines</strong>: </p> -<source> -DriverManager.registerDriver(new +<source><![CDATA[DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); conn = -DriverManager.getConnection("jdbc:oracle:oci8:@database","username","password"); -</source> +DriverManager.getConnection("jdbc:oracle:oci8:@database","username","password");]]></source> <p> where database is of the form <code>host:port:SID</code> Now if you try to access the URL of your test servlet/jsp and what you get is a @@ -553,6 +526,7 @@ test servlet/jsp and what you get is a </p> <p> First, the <code>UnsatisfiedLinkError</code> indicates that you have +</p> <ul> <li>a mismatch between your JDBC classes file and your Oracle client version. The giveaway here is the message stating that a needed library file cannot be @@ -564,7 +538,6 @@ Oracle client. The classeXXXs.zip file a the classes12.zip file from the directory <code>$ORAHOME\jdbc\lib</code> will also work. </li> </ul> -</p> <p> Next you may experience the error <code>ORA-06401 NETCMN: invalid driver designator</code> </p> @@ -641,8 +614,7 @@ of events which could cause this error i Here is an example of properly written code to use a database connection obtained from a connection pool: </p> -<pre> - Connection conn = null; +<source><![CDATA[ Connection conn = null; Statement stmt = null; // Or PreparedStatement if needed ResultSet rs = null; try { @@ -673,8 +645,7 @@ obtained from a connection pool: try { conn.close(); } catch (SQLException e) { ; } conn = null; } - } -</pre> + }]]></source> </subsection> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org