For example, i would like to download one zip file and one csv file in one response. Is there any way other than compressing these two files in one zip file.
相关问题
- Angular RxJS mergeMap types
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
Although ServletResponse is not meant to do this, we could programmatically tweak it to send multiple files, which all client browsers except IE seems to handle properly. A sample code snippet is given below.
This will not work in IE browsers. N.B - Try Catch blocks not included
No you can not do that. The reason is that whenever you want to sent any data in request you use steam available in request and retrive this data using
request.getRequestParameter("streamParamName").getInputStream()
, also please make a note if you have already consumed this stream once you will not be able to get it again.The example mentioned above is a tweak that google also uses in sending multipart email with multiple attachments. To achieve that they define boundaries for each attachment and client have to take care of these boundaries while retrieving this information and rendering it.
Code developed by Jason Hunter to handle servlet request and response having multiple parts has been the defacto since years. You can find it at servlets.com