Get form parameters from a multidisciplinary request without receiving files

I am looking for a way to get request form parameters with multiple HTTP parts in a servlet filter without uploading files (for now).

request.getParameterMap () returns empty. I understand that this is due to the fact that the request is multi-part.

I looked at commons.HttpFileUpload, but this seems to be too big for my situation. In this filter, I am only interested in the usual parameters and do not want to process file uploads yet.

Edit: The main problem is that I need to have an intact HttpRequestObject down the filter stack. HttpFileUpload seems to consume part of the request data (perhaps using the data stream object and closing it again.)

+3
source share
4 answers

This, of course, is not too much, this is the right way and is always better than writing the parser yourself. Apache Commons FileUpload has been developed and maintained for many years and has proven to be reliable in handling multipart / form-data requests. You do not want to reinvent the wheel. If you really want to do this (I do not recommend), read the multipart / form-data specification and start by reading HttpServletRequest#getInputStream()(warning: this is a combination of binary and character data!).

, Apache Commons FileUpload , , multipart/form-data, , Commons FileUpload ( ) , , , . , .

, .

+6
+4

, , CSRF -. JS , , ( , ).

, , . , .

, ( ), , JavaScript GET, .. URL- , , HttpServletRequest.getParameter() ( ).

IE, FF Chrome, , , .

, , .

+4

Commons FileUpload .

, :

JSP/Servlet?

0

Source: https://habr.com/ru/post/1723093/


All Articles