Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><em>It's been some time since I had to write a MIME parser for JSF, but this is what I remember about the process.</em></p> <p>You will need to write a parser to extract data from the <code>multi-part/formdata</code> payload. There is a good <a href="http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2" rel="nofollow">overview of <code>multi-part/formdata</code> on the W3 site</a>.</p> <p>You will need to decide whether to target:</p> <ul> <li>a non-JSF servlet with a plain form/controls</li> <li>a JSF servlet with a JSF form and a custom file-upload control</li> </ul> <p><strong>Targeting a plain servlet</strong></p> <p>This will be the simpler approach so long as the upload POST action doesn't need to invoke code that relies being in a JSF context (managed beans, etc.)</p> <p>Your servlet parses the data from the input stream and acts on it as appropriate.</p> <p><strong>Targeting a JSF view/action</strong></p> <p>Here you will need to decorated the request (ideally with a <a href="http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletRequestWrapper.html" rel="nofollow"><code>HttpServletRequestWrapper</code></a>) to provide the parsed <a href="http://docs.oracle.com/javaee/6/api/javax/servlet/ServletRequestWrapper.html#getParameterMap%28%29" rel="nofollow">parameters</a> to the JSF framework. This would generally be done in a <a href="http://docs.oracle.com/javaee/6/api/javax/servlet/Filter.html" rel="nofollow">filter</a> that detects the post type from the HTTP headers. Decisions need to be made about where the file data is stored prior to the invocation of any form actions and how you're going to expose that data to managed beans.</p> <p>You also need to consider whether you're going to create a custom JSF control for the file upload input type or whether you can get away with plain HTML elements.</p> <p><em>It is worth examining the features of the parsers/controls you can't use to ensure you provide simple features - like a maximum payload size to prevent attackers uploading gigabytes of data to your application.</em></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload