I am building a web-service that returns a multipart response. I know the format for constructing a multi-part response; and I will build my own tools if I can't find existing tools.
Perhaps I just need help with my google-foo. Everything I find is about POSTing or consuming multi-part messages. Nothing about producing multi-part responses.
You can use oreilly servlets http://www.servlets.com/cos/
An example is in the javadoc: http://www.servlets.com/cos/javadoc/com/oreilly/servlet/MultipartResponse.html
import com.oreilly.servlet.MultipartResponse
//javax.servlet.http.HttpServletResponse res
MultipartResponse multi = new MultipartResponse(res);
multi.startResponse("text/plain");
out.println("On your mark");
multi.endResponse();
try { Thread.sleep(1000); } catch (InterruptedException e) { }
multi.startResponse("text/plain");
out.println("Get set");
multi.endResponse();
try { Thread.sleep(1000); } catch (InterruptedException e) { }
multi.startResponse("image/gif");
ServletUtils.returnFile(req.getRealPath("/images/go.gif"), out);
multi.finish();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With