如何处理来自 servlet 的 jsp 响应以进行分段文件上传?
有两个网络应用程序。一位是客户,另一位是提供者。提供程序托管一个 servlet 来处理分段文件上传请求。客户端将文件上传到提供者 servlet。瓶颈是如何将响应发送回客户端。客户端需要根据提供商返回的响应进行处理。我们无法将请求和响应转发到 servlet/jsp,因为这两个应用程序位于不同的服务器中。那么如何在客户端捕获响应呢?
There are two web applications. One is a client and other one is the provider. The provider is hosting a servlet to process a multipart file upload request. The client will upload the file to the provider servlet. The bottleneck is how to send a response back to the client. The client need to process according to the response send back by the provider. We cannot forward the request and response to a servlet/jsp because both the applications are in different servers. Then how to trap the response in the client side?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需写入响应正文即可。
您甚至可以编写 XML 或 JSON,以便更容易地通过“客户端服务器”解析响应。
根据评论更新,该问题显然表述不当,您的实际问题位于其他地方。问题不在于响应处理,而在于请求处理。使用 JS/Ajax,您无法触发多部分/表单数据请求。您必须在隐藏的 HTML iframe 中使用 Flash 或 POST 表单。您可以在此处找到大量示例。我个人推荐 jQuery Form 插件。
Just write to the response body.
You can even write XML or JSON so that parsing the response by the "client server" is easier.
Update as per the comment, the question is apparently poorly formulated and your actual problem lies elsewhere. It's not the response handling which is the problem, but the request handling. With JS/Ajax you cannot fire multipart/form-data requests. You've got to use Flash or a POST form in a hidden HTML iframe. You can find plethora of examples here. I personally recommend jQuery Form plugin.