响应后获取控制权
我有一个 jsp 向另一台服务器中的 servlet 提交请求(当单击 PDF 图标时)。 Servlet 传输响应
response.setHeader("Content-disposition", "attachment;filename="+reportName.replace(" ","") + now +"."+fileExtension.toLowerCase()); ServletOutputStream outStream = response.getOutputStream(); byte[] 缓冲区 = 新字节[4 * 1024]; 整数数据; while((数据 = inputStream.read(buffer)) != -1) { outStream.write(缓冲区, 0, 数据); } outStream.flush(); 一切
都很好。问题 - 当我单击 PDF 图标时,我想禁用该图标,而当文件流式传输(或下载)时,我想启用该图标。我怎样才能实现这个目标?我如何知道回复何时返回?
还想.. AJAX 可能是唯一的选择?
I have a jsp submitting a request to a servlet (when PDF icon is clicked) in another server. The servlet streams the response
response.setHeader("Content-disposition", "attachment;filename="+reportName.replace(" ","") + now +"."+fileExtension.toLowerCase());
ServletOutputStream outStream = response.getOutputStream();
byte[] buffer = new byte[4 * 1024];
int data;
while((data = inputStream.read(buffer)) != -1)
{
outStream.write(buffer, 0, data);
}
outStream.flush();
Every thing works great. Problem - when I click on the PDF icon, I want to disable the icon and when the file is streamed (or downloaded) I want to enable the icon. How can I achieve this? How do I know when the response is back?
Also thinking.. AJAX may be the only option??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用会话变量并在单击后和流后切换值。然后使用 DWR 进行后续点击 - 检查会话变量并决定是否移至下一页。
Used a session variable and toggled the values after the click and after the stream. Then used DWR for the subsequent clicks - checked the session variable and decided to move to the next page or not.