-
Sending a file as an attachment with a servlet?
I am hvaing trouble sending a file as a result of a post in a HTML form
using a servlet. The file has to be generated for each request. .
After the user has recieved the file, then IE "hangs". It doesn't switch
screen when I press a hyperlink and I have to press "refresh" to continue. I
have included my code. Any help would be most appreciated!
String toSend = "<file><data>testdata</data></file>";
try
{
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition","attachment;
filename=Log.xml;");
PrintWriter out = response.getWriter();
out.println(toSend);
out.close();
}
catch (Exception e)
{
ServletOutputStream out = response.getOutputStream();
response.setContentType("text/html");
out.println("<html>");
out.println("<head><title>Error</title></head>");
out.println("An error has occured <br>");
out.println("</body>");
out.println("</html>");
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks