Pawan Nachnani wrote:
>
> Hello,
>
> I've been tasked with researching a cure for a problem we're experiencing
> with a Web-based application we're developing using JSP.
>
> In the application, there is a page with a submit button. Clicking that
> button calls a .jsp file with this code:
>
> <%@ page import="java.util.*" %>
>
> <%
> response.setContentType("application/octet-stream");
>
> response.setHeader("Content-disposition","attachment;filename=Foo.xml;");
>
> File file = new File("e:\\download\\Foo.xml"); //Known Directory.
>
> response.setContentLength((int)file.length());
>
> BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
> BufferedOutputStream dataOut = new
> BufferedOutputStream(response.getOutputStream());
>
> int b = 0;
> while ((b = in.read( )) != -1) {
> dataOut.write(b);
> }
> in.close();
> dataOut.close();
>
> %>
>
> The File Download dialog opens. Everything works as it should. However,
> after all dialog boxes are close, the cursor remains an hourglass (busy).
> Does anyone know why this happens or knows how to fix the problem?
In general, I suggest you use a regular servlet for this type of function
instead of a JSP page. JSP pages are nice when you have a mix of static
and dynamic content, since you don't have to generate the HTML with tons
of out.println() statements as you have to in a servlet. But here you don't
have any static content at all; the JSP page only contains Java code.
A JSP page that messes with the response directly, like setting the content
length and content type, may run into conflicts with how the JSP container
handles the response. That's one possible reason for what you see.
So, just because you have decided to use JSP for an application doesn't
mean you have to use it for everything. Use the best tool for each job,
and in this case, a servlet is probably a more appropriate choice.
Hans
--
Hans Bergsten [EMAIL PROTECTED]
Gefion Software http://www.gefionsoftware.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets