servlets - Download a file from the server in gwt -


i've made application using gwt , works far. creates file on server. try download file. tried with

    window.open(gwt.gethostpagebaseurl() + "file.xml", "file.xml", ""); 

but that, browser opens file, cause xml, instead of download it.

after tried with

    <iframe src="javascript:''" id="__gwt_downloadframe" tabindex='-1' style="position: absolute; width: 0; height: 0; border: 0; display: none;"></iframe> 

in web.xml ,

 public static void triggerdownload(final string url) {         if (url == null) {           throw new illegalargumentexception("url must not null");         } // if          if (downloadframe == null) {           downloadframe = frame.wrap(document.get().getelementbyid("__gwt_downloadframe"));         } // if         downloadframe.seturl(url);       } // triggerdownload() 

in client side, url=gwt.gethostpagebaseurl() + "epk.epml" this, theres happening nothing if click download button.

i've read download servlet, dont complete , dont work in way.

can of tell me i'm doing wrong or can give me matching example case?

best regards t.

it's opening xml file instead of downloading because servlet not telling browser should downloaded.

alter code of servlet , add before writing content response.

response.setcontenttype("application/octet-stream" );​ response.setheader(​"content-disposition","attachment; filename=\"" + filename +"\""); 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -