aspose file tools*
The moose likes Servlets and the fly likes IE Hangs when I use servlet to download a file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "IE Hangs when I use servlet to download a file" Watch "IE Hangs when I use servlet to download a file" New topic
Author

IE Hangs when I use servlet to download a file

Mrutyunjay Hanchinal
Ranch Hand

Joined: Sep 26, 2001
Posts: 50
Hi
I am downloading a HTML file by using servlet.
I have used following code
=================================================
res.setContentType("text/html");
res.setHeader("Content-disposition","attachment; filename" +"m.html" );
PrintWriter out=res.getWriter();
try
{
out.println"<html><head></head><body><h1>Mrutyunjay</h1></body></html>");
out.close();
}
catch(Exception e)
{
System.out.println("exception "+e);
e.printStackTrace();
}
=================================================
I am using IE. When ever I request for download It opens the download confirmation box and gives two options in windows
1. Open from current location
2. Save to disk
If I choose Save to disk it is working fine. If I choose open from current location then the IE hangs.
This works fine in Netscape.
Any answers for this?
Thanks
Mrutyunjay
[ March 05, 2002: Message edited by: Mrutyunjay Hanchinal ]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16061
    
  21

Some versions of IE have known bugs regarding the Content-disposition header


Customer surveys are for companies who didn't pay proper attention to begin with.
Christopher Dixon
Greenhorn

Joined: Jan 30, 2002
Posts: 22
This is a shot in the dark, but have you tried to set the content-length header to the number of bytes in your output? For a simple test, you could manually count, but for more complex output, write to a ByteArrayOutputStream. Just a guess...
Chris
Mrutyunjay Hanchinal
Ranch Hand

Joined: Sep 26, 2001
Posts: 50
HI
I think what Tim says is right.
I upgraded IE from 5.00 to 5.50 and the problem is solved
Thanks for the answers
Mrutyunjay
Mrutyunjay Hanchinal
Ranch Hand

Joined: Sep 26, 2001
Posts: 50
Hi
With respect to my above download problem, Can I disable "open this file from its current location" option in dialog box?
since I don't need that open in current location option.
I have seen in one of the site this being disabled.
I will be thankful for any Help
Regards
Mrutyunjay
[ March 06, 2002: Message edited by: Mrutyunjay Hanchinal ]
[ March 06, 2002: Message edited by: Mrutyunjay Hanchinal ]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16061
    
  21

Check the Microsoft online docs (MSDN) concerning their version of Content-Disposition. This is an IE-specific issue (more or less - I think other browsers have stolen it now). I believe they have added extensions to the standard Content-Disposition and one of them might do what you want.
Mrutyunjay Hanchinal
Ranch Hand

Joined: Sep 26, 2001
Posts: 50
HI Tim
If you could tell me what is the extension or the resource on the web which shows me how to disable the "Open this file from its current location" radio button in the download box which appears on downloading some file, It would be very helpful to me
Waiting fro your response
Thanks in advance
Mrutyunjay
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: IE Hangs when I use servlet to download a file