my dog learned polymorphism*
The moose likes JSP and the fly likes Problem while downloading file from server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Problem while downloading file from server" Watch "Problem while downloading file from server" New topic
Author

Problem while downloading file from server

sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415
Hi all

I have 2 frames in my jsp and the second frame has a file which is on the server and in the top frame i have download the file . On clicking this i go to server and i will flush the stream to the response by setting some headers .

Then a open/save dialog box comes up and after saving the file, nothing will work in my top frame as it says "Unspecified Error" at the client side (in javascript)

This is because the document is getting null after this .

can any one let me know what might be the problem .


Regards
Sreenath
Yuriy Zilbergleyt
Ranch Hand

Joined: Dec 13, 2004
Posts: 429
Out of curiosity, why do you have an entire frame devoted to downloading a file? I understand if it's a file that could be displayed within the frame, like a pdf or a movie for example, but if it's something that needs to be downloaded why not just have a link?

And as always the relevant samples of your code are always helpful.

-Yuriy
sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415
I have the bottom frame for showing the data in the file .if the user wants to download that

file (As its on the server ) we have this download option.

And coming to my top frame where there are few buttons

<a href="/export.do?id=test.html" class="two">Download</a> . When the user clicks download it goes to a servlet and sets the response headers as

1. response.setContentType("application/x-download");
2. response.setHeader("Content-Disposition", "attachment; filename=Report"+id+".zip");

and after open/save dilaog , i save this file .After this other functionalities in the same
page wont work and javascript error comes up on clicking saying "Unspecified error" .The reason is document object is not available for the frame .

But doing some research i got to know that there is some problem with the header 2 i am setting for the response .If i remove this everything works fine. but i cant remove that as the file name while saving will come as "export.do" for that file.

can any one tell me what might be the problem ?? r else is there any header substituting the header 2 so that i get appropriate file name
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem while downloading file from server
 
Similar Threads
window, frame, progressbar modal
Saving a ms word doc on the server
Access Denied error in Javascript
IDEA: web-based JSP editor for final markups...
Frameset Refresh Problem