[fileupload] - Replacing with HttpServletRequest.getParts() dynamically

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[fileupload] - Replacing with HttpServletRequest.getParts() dynamically

Yozons on Gmail
With FileUpload, our JSP pages (HTML documents) can be either
'application/x-www-form-urlencoded' or 'multipart/form-data' based on
whether the document includes files to be uploaded or not.

We don't currently assume all requests will include file uploads, and
with FileUpload, we are able to test the request to see if it's
multipart, and if so, do special coding using FileUpload.  It works
great, allow us to process either type of request.

However, when we looked to switch to the HttpServletRequest.getParts(),
it seems that the file upload logic is tied to a Servlet, requiring that
we annotate it at compile time with @MultipartConfig.  But since our
servlet is a common controller and not all requests will be multipart,
we're stuck as to how to accomplish both regular requests and file
upload requests.

Also, we have file uploads that may have different 'maxFileSize'
settings (and even 'location', which we don't know in advance since they
are turned by customer deployments) values tuned to the types of files
we're uploading.  But to tune these, we seem to require a servlet for
each combination and somehow need to know the location at compile time.

Is there a way to switch from FileUpload to the servlet standard
(getParts) so that we can accept any request from our servlet, and if we
determine it's multipart, then process it for file uploads, setting max
file sizes, etc. on a dynamic basis?

Thanks for any ideas...

To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]