响应后获得控制

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??

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.