struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [struts-site] branch asf-site updated: Updates production by Jenkins
Date Wed, 14 Nov 2018 07:01:08 GMT
This is an automated email from the ASF dual-hosted git repository.

git-site-role pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/struts-site.git


The following commit(s) were added to refs/heads/asf-site by this push:
     new 8d23209  Updates production by Jenkins
8d23209 is described below

commit 8d232094f6624d7166a457e9a78ecb2222cfa3db
Author: jenkins <builds@apache.org>
AuthorDate: Wed Nov 14 07:01:06 2018 +0000

    Updates production by Jenkins
---
 content/core-developers/file-upload.html | 209 ++++++++++++++++++-------------
 1 file changed, 125 insertions(+), 84 deletions(-)

diff --git a/content/core-developers/file-upload.html b/content/core-developers/file-upload.html
index 1258914..5c0e789 100644
--- a/content/core-developers/file-upload.html
+++ b/content/core-developers/file-upload.html
@@ -127,13 +127,48 @@
   <section class="col-md-12">
     <a href="index.html" title="back to Core Developers Guide"><< back to Core
Developers Guide</a>
     <a class="edit-on-gh" href="https://github.com/apache/struts-site/edit/master/source/core-developers/file-upload.md"
title="Edit this page on GitHub">Edit on GitHub</a>
-    <h1 id="file-upload">File Upload</h1>
-
-<p>The Struts 2 framework provides built-in support for processing file uploads that
conform to <a href="http://www\.ietf\.org/rfc/rfc1867\.txt">RFC 1867</a>^[http://www.ietf.org/rfc/rfc1867.txt],
“Form-based File Upload in HTML”. When correctly configured the framework will pass uploaded
file(s) into your Action class. Support for individual and multiple file uploads are provided.
When a file is uploaded it will typically be stored in a temporary directory. Uploaded files
should be proc [...]
+    <h1 class="no_toc" id="file-upload">File Upload</h1>
+
+<ul id="markdown-toc">
+  <li><a href="#dependencies" id="markdown-toc-dependencies">Dependencies</a>
   <ul>
+      <li><a href="#struts-20x-file-upload-dependencies" id="markdown-toc-struts-20x-file-upload-dependencies">Struts
2.0.x File Upload Dependencies</a></li>
+      <li><a href="#struts-21x-file-upload-dependencies" id="markdown-toc-struts-21x-file-upload-dependencies">Struts
2.1.x File Upload Dependencies</a></li>
+    </ul>
+  </li>
+  <li><a href="#basic-usage" id="markdown-toc-basic-usage">Basic Usage</a>
   <ul>
+      <li><a href="#example-action-mapping" id="markdown-toc-example-action-mapping">Example
action mapping:</a></li>
+      <li><a href="#example-jsp-form-tags" id="markdown-toc-example-jsp-form-tags">Example
JSP form tags:</a></li>
+      <li><a href="#example-action-class" id="markdown-toc-example-action-class">Example
Action class:</a></li>
+    </ul>
+  </li>
+  <li><a href="#uploading-multiple-files" id="markdown-toc-uploading-multiple-files">Uploading
Multiple Files</a>    <ul>
+      <li><a href="#uploading-multiple-files-using-arrays" id="markdown-toc-uploading-multiple-files-using-arrays">Uploading
Multiple Files using Arrays</a></li>
+      <li><a href="#uploading-multiple-files-using-lists" id="markdown-toc-uploading-multiple-files-using-lists">Uploading
Multiple Files using Lists</a></li>
+    </ul>
+  </li>
+  <li><a href="#advanced-configuration" id="markdown-toc-advanced-configuration">Advanced
Configuration</a>    <ul>
+      <li><a href="#file-size-limits" id="markdown-toc-file-size-limits">File
Size Limits</a></li>
+      <li><a href="#file-types" id="markdown-toc-file-types">File Types</a></li>
+      <li><a href="#error-messages" id="markdown-toc-error-messages">Error Messages</a></li>
+      <li><a href="#temporary-directories" id="markdown-toc-temporary-directories">Temporary
Directories</a></li>
+      <li><a href="#alternate-libraries" id="markdown-toc-alternate-libraries">Alternate
Libraries</a></li>
+      <li><a href="#request-validation" id="markdown-toc-request-validation">Request
validation</a></li>
+      <li><a href="#disabling-file-upload-support" id="markdown-toc-disabling-file-upload-support">Disabling
file upload support</a></li>
+    </ul>
+  </li>
+</ul>
+
+<p>The Struts 2 framework provides built-in support for processing file uploads that
conform to <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a>, 
+“Form-based File Upload in HTML”. When correctly configured the framework will pass uploaded
file(s) into your Action class. 
+Support for individual and multiple file uploads are provided. When a file is uploaded it
will typically be stored in a temporary directory. 
+Uploaded files should be processed or moved by your Action class to ensure the data is not
lost. Be aware that servers may have a security 
+policy in place that prohibits you from writing to directories other than the temporary directory
and the directories that belong to your 
+web application.</p>
 
 <h2 id="dependencies">Dependencies</h2>
 
-<p>The Struts 2 framework leverages add-on libraries to handle the parsing of uploaded
files. These libraries are not included in the Struts distribution, you must add them into
your project. The libraries needed are:</p>
+<p>The Struts 2 framework leverages add-on libraries to handle the parsing of uploaded
files. These libraries are not included in the Struts 
+distribution, you must add them into your project. The libraries needed are:</p>
 
 <table>
   <thead>
@@ -148,14 +183,14 @@
   <tbody>
     <tr>
       <td>Commons-FileUpload</td>
-      <td><a href="http://commons\.apache\.org/fileupload/">http://commons.apache.org/fileupload/</a></td>
+      <td><a href="http://commons.apache.org/fileupload/">http://commons.apache.org/fileupload/</a></td>
       <td>1.1.1</td>
       <td>1.2.1</td>
       <td>1.3.2</td>
     </tr>
     <tr>
       <td>Commons-IO</td>
-      <td><a href="http://commons\.apache\.org/io/">http://commons.apache.org/io/</a></td>
+      <td><a href="http://commons.apache.org/io/">http://commons.apache.org/io/</a></td>
       <td>1.0</td>
       <td>1.3.2</td>
       <td>2.4</td>
@@ -165,7 +200,7 @@
 
 <p>If you are using Maven then you can add these libraries as dependencies in your
project’s pom.xml.</p>
 
-<p><strong>Struts 2.0.x File Upload Dependencies</strong></p>
+<h3 id="struts-20x-file-upload-dependencies">Struts 2.0.x File Upload Dependencies</h3>
 
 <div class="highlighter-rouge"><pre class="highlight"><code><span class="nt">&lt;dependency&gt;</span>
     <span class="nt">&lt;groupId&gt;</span>commons-fileupload<span
class="nt">&lt;/groupId&gt;</span>
@@ -177,11 +212,10 @@
     <span class="nt">&lt;artifactId&gt;</span>commons-io<span class="nt">&lt;/artifactId&gt;</span>
     <span class="nt">&lt;version&gt;</span>1.0<span class="nt">&lt;/version&gt;</span>
 <span class="nt">&lt;/dependency&gt;</span>
-
 </code></pre>
 </div>
 
-<p><strong>Struts 2.1.x File Upload Dependencies</strong></p>
+<h3 id="struts-21x-file-upload-dependencies">Struts 2.1.x File Upload Dependencies</h3>
 
 <div class="highlighter-rouge"><pre class="highlight"><code><span class="nt">&lt;dependency&gt;</span>
     <span class="nt">&lt;groupId&gt;</span>commons-fileupload<span
class="nt">&lt;/groupId&gt;</span>
@@ -193,15 +227,16 @@
     <span class="nt">&lt;artifactId&gt;</span>commons-io<span class="nt">&lt;/artifactId&gt;</span>
     <span class="nt">&lt;version&gt;</span>1.3.2<span class="nt">&lt;/version&gt;</span>
 <span class="nt">&lt;/dependency&gt;</span>
-
 </code></pre>
 </div>
 
 <h2 id="basic-usage">Basic Usage</h2>
 
-<p>The <code class="highlighter-rouge">org.apache.struts2.interceptor.FileUploadInterceptor</code>
class is included as part of the <code class="highlighter-rouge">defaultStack</code>.
As long as the required libraries are added to your project you will be able to take advantage
of of the Struts 2 fileUpload capability. Configure an Action mapping for your Action class
as you typically would.</p>
+<p>The <code class="highlighter-rouge">org.apache.struts2.interceptor.FileUploadInterceptor</code>
class is included as part of the <code class="highlighter-rouge">defaultStack</code>.
As long as the required libraries 
+are added to your project you will be able to take advantage of of the Struts 2 fileUpload
capability. Configure an Action mapping for your 
+Action class as you typically would.</p>
 
-<p><strong>Example action mapping:</strong></p>
+<h3 id="example-action-mapping">Example action mapping:</h3>
 
 <div class="highlighter-rouge"><pre class="highlight"><code><span class="nt">&lt;action</span>
<span class="na">name=</span><span class="s">"doUpload"</span> <span
class="na">class=</span><span class="s">"com.example.UploadAction"</span><span
class="nt">&gt;</span>
     <span class="nt">&lt;result</span> <span class="na">name=</span><span
class="s">"success"</span><span class="nt">&gt;</span>good_result.jsp<span
class="nt">&lt;/result&gt;</span>
@@ -210,22 +245,23 @@
 </code></pre>
 </div>
 
-<p>A form must be create with a form field of type file, <code class="highlighter-rouge">&lt;INPUT
type="file" name="upload"&gt;</code>. The form used to upload the file must have
its encoding type set to multipart/form-data, 
-<code class="highlighter-rouge">&lt;FORM action="doUpload" enctype="multipart/form-data"
method="post"&gt;</code>. The standard procedure for adding these elements is by
using the Struts 2 tag libraries as shown in the following example:</p>
+<p>A form must be create with a form field of type file, <code class="highlighter-rouge">&lt;INPUT
type="file" name="upload"&gt;</code>. The form used to upload the file must have
its 
+encoding type set to <code class="highlighter-rouge">multipart/form-data</code>,
<code class="highlighter-rouge">&lt;form action="doUpload" enctype="multipart/form-data"
method="post"&gt;</code>. The standard procedure 
+for adding these elements is by using the Struts 2 tag libraries as shown in the following
example:</p>
 
-<p><strong>Example JSP form tags:</strong></p>
+<h3 id="example-jsp-form-tags">Example JSP form tags:</h3>
 
 <div class="highlighter-rouge"><pre class="highlight"><code>   <span
class="nt">&lt;s:form</span> <span class="na">action=</span><span
class="s">"doUpload"</span> <span class="na">method=</span><span class="s">"post"</span>
<span class="na">enctype=</span><span class="s">"multipart/form-data"</span><span
class="nt">&gt;</span>
        <span class="nt">&lt;s:file</span> <span class="na">name=</span><span
class="s">"upload"</span> <span class="na">label=</span><span class="s">"File"</span><span
class="nt">/&gt;</span>
        <span class="nt">&lt;s:submit/&gt;</span>
    <span class="nt">&lt;/s:form&gt;</span>
-
 </code></pre>
 </div>
 
-<p>The fileUpload interceptor will use setter injection to insert the uploaded file
and related data into your Action class. For a form field named <strong>upload</strong>
you would provide the three setter methods shown in the following example:</p>
+<p>The fileUpload interceptor will use setter injection to insert the uploaded file
and related data into your Action class. For a form field 
+named <code class="highlighter-rouge">upload</code> you would provide the three
setter methods shown in the following example:</p>
 
-<p><strong>Example Action class:</strong></p>
+<h3 id="example-action-class">Example Action class:</h3>
 
 <div class="highlighter-rouge"><pre class="highlight"><code><span class="kn">package</span>
<span class="n">com</span><span class="o">.</span><span class="na">example</span><span
class="o">;</span>
 
@@ -258,7 +294,8 @@
 </code></pre>
 </div>
 
-<p>The purpose of each one of these methods is described in the table below. Notice
that if you have multiple file form elements with different names you would be required to
have another corresponding set of these methods for each file uploaded.</p>
+<p>The purpose of each one of these methods is described in the table below. Notice
that if you have multiple file form elements with different 
+names you would be required to have another corresponding set of these methods for each file
uploaded.</p>
 
 <table>
   <thead>
@@ -269,15 +306,15 @@
   </thead>
   <tbody>
     <tr>
-      <td>setX(File file)</td>
+      <td><code class="highlighter-rouge">setX(File file)</code></td>
       <td>The file that contains the content of the uploaded file. This is a temporary
file and file.getName() will not return the original name of the file</td>
     </tr>
     <tr>
-      <td>setXContentType(String contentType)</td>
+      <td><code class="highlighter-rouge">setXContentType(String contentType)</code></td>
       <td>The mime type of the uploaded file</td>
     </tr>
     <tr>
-      <td>setXFileName(String fileName)</td>
+      <td><code class="highlighter-rouge">setXFileName(String fileName)</code></td>
       <td>The actual file name of the uploaded file (not the HTML name)</td>
     </tr>
   </tbody>
@@ -285,11 +322,15 @@
 
 <h2 id="uploading-multiple-files">Uploading Multiple Files</h2>
 
-<p>As mentioned in the previous section one technique for uploading multiple files
would be to simply have multiple form input elements of type file all with different names.
This would require a number of setter methods that was equal to 3 times the number of files
being uploaded. Another option is to use Arrays or java.util.Lists. The following examples
are taken from the Showcase example application that is part sample applications you can download
at <a href="http://struts\.apache\.o [...]
+<p>As mentioned in the previous section one technique for uploading multiple files
would be to simply have multiple form input elements of type 
+file all with different names. This would require a number of setter methods that was equal
to 3 times the number of files being uploaded. 
+Another option is to use Arrays or java.util.Lists. The following examples are taken from
the Showcase example application that is part 
+sample applications you can download at <a href="http://struts.apache.org/download.cgi">http://struts.apache.org/download.cgi</a>.
For the Action mapping 
+details see <code class="highlighter-rouge">struts-fileupload.xml</code> in the
sample application download.</p>
 
-<p><strong>Uploading Multiple Files using Arrays</strong></p>
+<h3 id="uploading-multiple-files-using-arrays">Uploading Multiple Files using Arrays</h3>
 
-<p><strong>multipleUploadUsingArray.jsp</strong> Notice all file input
types have the same name.</p>
+<p><code class="highlighter-rouge">multipleUploadUsingArray.jsp</code>
Notice all file input types have the same name.</p>
 
 <pre><code class="language-jsp">&lt;s:form action="doMultipleUploadUsingArray"
method="POST" enctype="multipart/form-data"&gt;
   &lt;s:file label="File (1)" name="upload" /&gt;
@@ -299,12 +340,7 @@
 &lt;/s:form&gt;
 </code></pre>
 
-<p><strong>MultipleFileUploadUsingArrayAction.java</strong></p>
-
-<p> </p>
-
-<p>**
-**</p>
+<p><code class="highlighter-rouge">MultipleFileUploadUsingArrayAction.java</code></p>
 
 <div class="highlighter-rouge"><pre class="highlight"><code><span class="kd">public</span>
<span class="kd">class</span> <span class="nc">MultipleFileUploadUsingArrayAction</span>
<span class="kd">extends</span> <span class="n">ActionSupport</span>
<span class="o">{</span>
 	<span class="kd">private</span> <span class="n">File</span><span
class="o">[]</span> <span class="n">uploads</span><span class="o">;</span>
@@ -350,11 +386,9 @@
 </code></pre>
 </div>
 
-<p> </p>
+<h3 id="uploading-multiple-files-using-lists">Uploading Multiple Files using Lists</h3>
 
-<p><strong>Uploading Multiple Files using Lists</strong></p>
-
-<p><strong>multipleUploadUsingList.jsp</strong> Notice all file input types
have the same name.</p>
+<p><code class="highlighter-rouge">multipleUploadUsingList.jsp</code> Notice
all file input types have the same name.</p>
 
 <pre><code class="language-jsp">&lt;s:form action="doMultipleUploadUsingList"
method="POST" enctype="multipart/form-data"&gt;
   &lt;s:file label="File (1)" name="upload" /&gt;
@@ -364,7 +398,7 @@
 &lt;/s:form&gt;
 </code></pre>
 
-<p><strong>MultipleFileUploadUsingListAction.java</strong></p>
+<p><code class="highlighter-rouge">MultipleFileUploadUsingListAction.java</code></p>
 
 <div class="highlighter-rouge"><pre class="highlight"><code><span class="kd">public</span>
<span class="kd">class</span> <span class="nc">MultipleFileUploadUsingListAction</span>
<span class="kd">extends</span> <span class="n">ActionSupport</span>
<span class="o">{</span>
 	<span class="kd">private</span> <span class="n">List</span><span
class="o">&lt;</span><span class="n">File</span><span class="o">&gt;</span>
<span class="n">uploads</span> <span class="o">=</span> <span class="k">new</span>
<span class="n">ArrayList</span><span class="o">&lt;</span><span
class="n">File</span><span class="o">&gt;();</span>
@@ -412,29 +446,19 @@
 
 <h2 id="advanced-configuration">Advanced Configuration</h2>
 
-<p>The Struts 2 <code class="highlighter-rouge">default.properties</code>
file defines several settings that affect the behavior of file uploading. You may find in
necessary to change these values. The names and default values are:</p>
+<p>The Struts 2 <code class="highlighter-rouge">default.properties</code>
file defines several settings that affect the behavior of file uploading. You may find in
necessary 
+to change these values. The names and default values are:</p>
 
 <div class="highlighter-rouge"><pre class="highlight"><code>struts.multipart.parser=jakarta
 struts.multipart.saveDir=
 struts.multipart.maxSize=2097152
-
 </code></pre>
 </div>
 
-<table>
-  <tbody>
-    <tr>
-      <td>Please remember that the <strong>struts.multipart.maxSize</strong>
is the size limit of the whole request, which means when you uploading multiple files, the
sum of their size must be below the <strong>struts.multipart.maxSize</strong>!</td>
-    </tr>
-  </tbody>
-</table>
-
-<table>
-  <tbody>
-    <tr>
-    </tr>
-  </tbody>
-</table>
+<blockquote>
+  <p>Please remember that the <code class="highlighter-rouge">struts.multipart.maxSize</code>
is the size limit of the whole request, which means when you uploading multiple files, 
+the sum of their size must be below the <code class="highlighter-rouge">struts.multipart.maxSize</code>!</p>
+</blockquote>
 
 <p>In order to change theses settings you define a constant in your applications <code
class="highlighter-rouge">struts.xml</code> file like so:</p>
 
@@ -446,7 +470,6 @@ struts.multipart.maxSize=2097152
     <span class="nt">&lt;constant</span> <span class="na">name=</span><span
class="s">"struts.multipart.maxSize"</span> <span class="na">value=</span><span
class="s">"1000000"</span> <span class="nt">/&gt;</span>
     ...
 <span class="nt">&lt;/struts&gt;</span>
-
 </code></pre>
 </div>
 
@@ -462,14 +485,17 @@ struts.multipart.maxSize=2097152
 
     <span class="nt">&lt;result</span> <span class="na">name=</span><span
class="s">"success"</span><span class="nt">&gt;</span>good_result.jsp<span
class="nt">&lt;/result&gt;</span>
 <span class="nt">&lt;/action&gt;</span>
-
 </code></pre>
 </div>
 
-<p><strong>File Size Limits</strong></p>
+<h3 id="file-size-limits">File Size Limits</h3>
 
-<p>There are two separate file size limits. First is <code class="highlighter-rouge">struts.multipart.maxSize</code>
which comes from the Struts 2 <code class="highlighter-rouge">default.properties</code>
file. This setting exists for security reasons to prohibit a malicious user from uploading
extremely large files to file up your servers disk space. This setting defaults to approximately
2 megabytes and should be adjusted to the maximum size file (2 gigs max) that your will need
the fr [...]
-<code class="highlighter-rouge">maximumSize</code>, is an interceptor setting
that is used to ensure a particular Action does not receive a file that is too large. Notice
the locations of both settings in the following example:</p>
+<p>There are two separate file size limits. First is <code class="highlighter-rouge">struts.multipart.maxSize</code>
which comes from the Struts 2 <code class="highlighter-rouge">default.properties</code>
file. 
+This setting exists for security reasons to prohibit a malicious user from uploading extremely
large files to file up your servers disk space. 
+This setting defaults to approximately 2 megabytes and should be adjusted to the maximum
size file (2 gigs max) that your will need the framework 
+to receive. If you are uploading more than one file on a form the <code class="highlighter-rouge">struts.multipart.maxSize</code>
applies to the combined total, not the individual 
+file sizes. The other setting, <code class="highlighter-rouge">maximumSize</code>,
is an interceptor setting that is used to ensure a particular Action does not receive a file

+that is too large. Notice the locations of both settings in the following example:</p>
 
 <div class="highlighter-rouge"><pre class="highlight"><code><span class="cp">&lt;?xml
version="1.0" encoding="UTF-8"?&gt;</span>
 <span class="cp">&lt;!DOCTYPE struts PUBLIC 
@@ -493,9 +519,10 @@ struts.multipart.maxSize=2097152
 </code></pre>
 </div>
 
-<p><strong>File Types</strong></p>
+<h3 id="file-types">File Types</h3>
 
-<p>There are two ways to limit the uploaded file type, declaratively and programmatically.
To declaratively limit the file type a comma separated list of allowedTypes can be specified
as a fileUpload interceptor param as shown in the following example:</p>
+<p>There are two ways to limit the uploaded file type, decoratively and programmatically.
To decoratively limit the file type a comma separated 
+list of allowedTypes can be specified as a fileUpload interceptor param as shown in the following
example:</p>
 
 <div class="highlighter-rouge"><pre class="highlight"><code><span class="nt">&lt;action</span>
<span class="na">name=</span><span class="s">"doUpload"</span> <span
class="na">class=</span><span class="s">"com.example.UploadAction"</span><span
class="nt">&gt;</span>
     <span class="nt">&lt;interceptor-ref</span> <span class="na">name=</span><span
class="s">"basicStack"</span><span class="nt">/&gt;</span>
@@ -507,15 +534,19 @@ struts.multipart.maxSize=2097152
 
     <span class="nt">&lt;result</span> <span class="na">name=</span><span
class="s">"success"</span><span class="nt">&gt;</span>good_result.jsp<span
class="nt">&lt;/result&gt;</span>
 <span class="nt">&lt;/action&gt;</span>
-
 </code></pre>
 </div>
 
-<p>When the uploaded file type does not match one of the MIME types specified a field
error will be created as described in the next section entitled Error Messages. Programmatically
limiting the file type means using the information passed in to your Action class via the
<code class="highlighter-rouge">setXContentType(String contentType)</code> method.
The benefit to this type of approach would be that it’s more flexible and no interceptor
configuration would be needed if file sizes are [...]
+<p>When the uploaded file type does not match one of the MIME types specified a field
error will be created as described in the next section 
+entitled Error Messages. Programmatically limiting the file type means using the information
passed in to your Action class via 
+the <code class="highlighter-rouge">setXContentType(String contentType)</code>
method. The benefit to this type of approach would be that it’s more flexible and no interceptor

+configuration would be needed if file sizes are keep under 2 megs.</p>
 
-<p><strong>Error Messages</strong></p>
+<h3 id="error-messages">Error Messages</h3>
 
-<p>If an error occurs several field errors will be added assuming that the action implements
<code class="highlighter-rouge">com.opensymphony.xwork2.ValidationAware</code>
or extends <code class="highlighter-rouge">com.opensymphony.xwork2.ActionSupport</code>.
These error messages are based on several i18n values stored in struts-messages.properties,
a default i18n file processed for all i18n requests. You can override the text of these messages
by providing text for the following keys:</p>
+<p>If an error occurs several field errors will be added assuming that the action implements
<code class="highlighter-rouge">com.opensymphony.xwork2.ValidationAware</code>

+or extends <code class="highlighter-rouge">com.opensymphony.xwork2.ActionSupport</code>.
These error messages are based on several i18n values stored in struts-messages.properties,

+a default i18n file processed for all i18n requests. You can override the text of these messages
by providing text for the following keys:</p>
 
 <table>
   <thead>
@@ -526,59 +557,70 @@ struts.multipart.maxSize=2097152
   </thead>
   <tbody>
     <tr>
-      <td>struts.messages.error.uploading</td>
+      <td><code class="highlighter-rouge">struts.messages.error.uploading</code></td>
       <td>A general error that occurs when the file could not be uploaded</td>
     </tr>
     <tr>
-      <td>struts.messages.error.file.too.large</td>
+      <td><code class="highlighter-rouge">struts.messages.error.file.too.large</code></td>
       <td>Occurs when the uploaded file is too large as specified by maximumSize.</td>
     </tr>
     <tr>
-      <td>struts.messages.error.content.type.not.allowed</td>
+      <td><code class="highlighter-rouge">struts.messages.error.content.type.not.allowed</code></td>
       <td>Occurs when the uploaded file does not match the expected content types specified</td>
     </tr>
     <tr>
-      <td>struts.messages.error.file.extension.not.allowed</td>
+      <td><code class="highlighter-rouge">struts.messages.error.file.extension.not.allowed</code></td>
       <td>Occurs when uploaded file has disallowed extension</td>
     </tr>
     <tr>
-      <td>struts.messages.upload.error.SizeLimitExceededException</td>
+      <td><code class="highlighter-rouge">struts.messages.upload.error.SizeLimitExceededException</code></td>
       <td>Occurs when the upload request (as a whole) exceed configured <strong>struts.multipart.maxSize</strong></td>
     </tr>
     <tr>
-      <td>struts.messages.upload.error.&lt;Exception class SimpleName&gt;</td>
+      <td><code class="highlighter-rouge">struts.messages.upload.error.&lt;Exception
class SimpleName&gt;</code></td>
       <td>Occurs when any other exception took place during file upload process</td>
     </tr>
   </tbody>
 </table>
 
-<p><strong>Temporary Directories</strong></p>
+<h3 id="temporary-directories">Temporary Directories</h3>
 
-<p>All uploaded files are saved to a temporary directory by the framework before being
passed in to an Action. Depending on the allowed file sizes it may be necessary to have the
framework store these temporary files in an alternate location. To do this change <code
class="highlighter-rouge">struts.multipart.saveDir</code> to the directory where
the uploaded files will be placed. If this property is not set it defaults to <code class="highlighter-rouge">javax.servlet.context.tempdir</cod
[...]
+<p>All uploaded files are saved to a temporary directory by the framework before being
passed in to an Action. Depending on the allowed file 
+sizes it may be necessary to have the framework store these temporary files in an alternate
location. To do this change <code class="highlighter-rouge">struts.multipart.saveDir</code>

+to the directory where the uploaded files will be placed. If this property is not set it
defaults to <code class="highlighter-rouge">javax.servlet.context.tempdir</code>.

+Keep in mind that on some operating systems, like Solaris, <code class="highlighter-rouge">/tmp</code>
is memory based and files stored in that directory would consume 
+an amount of RAM approximately equal to the size of the uploaded file.</p>
 
-<p><strong>Alternate Libraries</strong></p>
+<h3 id="alternate-libraries">Alternate Libraries</h3>
 
-<p>The <code class="highlighter-rouge">struts.multipart.parser</code> used
by the fileUpload interceptor to handle HTTP POST requests, encoded using the MIME-type multipart/form-data,
can be changed out. Currently there are two choices, jakarta and pell. The jakarta parser
is a standard part of the Struts 2 framework needing only its required libraries added to
a project. The pell parser uses Jason Pell’s multipart parser instead of the Commons-FileUpload
library. The pell parser is a St [...]
+<p>The <code class="highlighter-rouge">struts.multipart.parser</code> used
by the fileUpload interceptor to handle HTTP POST requests, encoded using the MIME-type <code
class="highlighter-rouge">multipart/form-data</code>, 
+can be changed out. Currently there are two choices, jakarta and pell. The jakarta parser
is a standard part of the Struts 2 framework needing 
+only its required libraries added to a project. The pell parser uses Jason Pell’s multipart
parser instead of the Commons-FileUpload library. 
+The pell parser is a Struts 2 plugin, for more details see: <a href="../plugins/pell/">Pell
multipart plugin</a>. There was a third alternative, cos, but it was removed 
+due to licensing incompatibilities.</p>
 
-<p>As from Struts version 2.3.18 a new implementation of <code class="highlighter-rouge">MultiPartRequest</code>
was added - <code class="highlighter-rouge">JakartaStreamMultiPartRequest</code>.
It can be used to handle large files, see <a href="https://issues\.apache\.org/jira/browse/WW\-3025">WW-3025</a>^[https://issues.apache.org/jira/browse/WW-3025]
for more details, but you can simple set</p>
+<p>As from Struts version 2.3.18 a new implementation of <code class="highlighter-rouge">MultiPartRequest</code>
was added - <code class="highlighter-rouge">JakartaStreamMultiPartRequest</code>.
It can be used to handle 
+large files, see <a href="https://issues.apache.org/jira/browse/WW-3025">WW-3025</a>
for more details, but you can simple set</p>
 
-<blockquote>
-  <p>&lt;constant name=”struts.multipart.parser” value=”jakarta-stream”
/&gt;</p>
-</blockquote>
+<div class="highlighter-rouge"><pre class="highlight"><code>&lt;constant
name="struts.multipart.parser" value="jakarta-stream" /&gt;
+</code></pre>
+</div>
 
 <p>in struts.xml to start using it.</p>
 
-<p><strong>Request validation</strong></p>
+<h3 id="request-validation">Request validation</h3>
 
-<p>The <code class="highlighter-rouge">struts.multipart.validationRegex</code>
is used to define a RegEx to be used to validate if the incoming request is a multipart request.
The request must use the <code class="highlighter-rouge">POST</code> method and
match the RegEx, by default the RegEx is defined as follow:</p>
+<p>The <code class="highlighter-rouge">struts.multipart.validationRegex</code>
is used to define a RegEx to be used to validate if the incoming request is a multipart request.

+The request must use the <code class="highlighter-rouge">POST</code> method
and match the RegEx, by default the RegEx is defined as follow:</p>
 
 <div class="highlighter-rouge"><pre class="highlight"><code>^multipart\\/form-data(;
boundary=[a-zA-Z0-9]{1,70})?
 </code></pre>
 </div>
 
-<p>Please read <a href="https://www\.w3\.org/Protocols/rfc1341/7\_2\_Multipart\.html">RFC1341</a>^[https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html]
the <strong>Multipart section</strong> for more details, existing Struts <code
class="highlighter-rouge">Multipart</code> parsers support only <code class="highlighter-rouge">multipart/form-data</code>
content type. This option is available since Struts 2.3.11.</p>
+<p>Please read <a href="https://www.w3.org/Protocols/rfc1341/7\_2\_Multipart.html">RFC1341</a>
the <strong>Multipart section</strong> for more details, existing 
+Struts <code class="highlighter-rouge">Multipart</code> parsers support only
<code class="highlighter-rouge">multipart/form-data</code> content type. This
option is available since Struts 2.3.11.</p>
 
-<p><strong>Disabling file upload support</strong></p>
+<h3 id="disabling-file-upload-support">Disabling file upload support</h3>
 
 <p>You can alternatively disable the whole file upload mechanism defining a constant
in <code class="highlighter-rouge">struts.xml</code>:</p>
 
@@ -586,9 +628,8 @@ struts.multipart.maxSize=2097152
 </code></pre>
 </div>
 
-<p>With this constant in place, Struts will ignore a <code class="highlighter-rouge">Content-Type</code>
header and will treat each request as an ordinary http request. This option is available since
Struts 2.3.11.</p>
-
-<p> </p>
+<p>With this constant in place, Struts will ignore a <code class="highlighter-rouge">Content-Type</code>
header and will treat each request as an ordinary http request. 
+This option is available since Struts 2.3.11. </p>
 
   </section>
 </article>


Mime
View raw message