Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Download does not work in IE
Download does not work in IE [message #637682] Mon, 08 November 2010 10:43 Go to next message
Patrick is currently offline PatrickFriend
Messages: 55
Registered: July 2009
Member
Hello,
I generate a file dynamically with a IServiceHandler and I use
ExternalBrowser for the download.
It works with Firefox, Chrome, and others, except Internet Explorer.
With IE (v8.0) a blank window seems to flicker briefly, but no download
happens.
Any idea please?
--
Patrick
Re: Download does not work in IE [message #638258 is a reply to message #637682] Wed, 10 November 2010 14:17 Go to previous messageGo to next message
Patrick is currently offline PatrickFriend
Messages: 55
Registered: July 2009
Member
Le 08/11/2010 11:43, Patrick a écrit :
> Hello,
> I generate a file dynamically with a IServiceHandler and I use
> ExternalBrowser for the download.
> It works with Firefox, Chrome, and others, except Internet Explorer.
> With IE (v8.0) a blank window seems to flicker briefly, but no download
> happens.

Am I the only one having this problem?
Here is my code. Any help is welcome. Thank you.

public class ApplicationActionBarAdvisor extends ActionBarAdvisor {

private IAction action;

public static final String serviceHandlerId = "download";

static {
IServiceManager manager = RWT.getServiceManager ();
IServiceHandler handler = new DownloadHandler ();
manager.registerServiceHandler (serviceHandlerId, handler);
}

public ApplicationActionBarAdvisor (IActionBarConfigurer configurer) {
super (configurer);
}

protected void makeActions (IWorkbenchWindow window) {
action = new DownloadAction ();
}

protected void fillMenuBar (IMenuManager menuBar) {
MenuManager menu = new MenuManager ("File");
menu.add (action);
menuBar.add (menu);
}

private static class DownloadAction extends Action {
public DownloadAction () {
setId (DownloadAction.class.getSimpleName ());
setText ("Download");
}
public void run () {
StringBuilder url = new StringBuilder ();
url.append (RWT.getRequest ().getContextPath ());
url.append (RWT.getRequest ().getServletPath ());
url.append ("?");
url.append (IServiceHandler.REQUEST_PARAM);
url.append ("=");
url.append (serviceHandlerId);
ExternalBrowser.open ("_blank",
RWT.getResponse ().encodeURL (url.toString ()), 0);
}
}

private static class DownloadHandler implements IServiceHandler {
public void service () throws IOException, ServletException {
HttpServletResponse response = RWT.getResponse ();
response.setContentType ("text/csv");
response.setHeader ("Content-Disposition",
"attachment; filename=\"test.csv\"");
response.getOutputStream ().print ("a,1\n");
response.getOutputStream ().print ("b,2\n");
response.flushBuffer ();
}
}
}
Re: Download does not work in IE [message #643718 is a reply to message #638258] Wed, 08 December 2010 00:23 Go to previous messageGo to next message
Benjamin Wolff is currently offline Benjamin WolffFriend
Messages: 136
Registered: July 2009
Senior Member
Hi,

today i also became aware of this problem with the (damned) IE 8.
The problem is, that the default security options of the IE don't generally allow a download. Instead, a warning at the top of the browser appears and you have to allow it manually (similar to the pop-up blocker). That's why the external browser window is closed immediately. One solution would be to lower the security restrictions in the IE: Options -> Security -> "Anpassen" (i don't know what it is called in the english version, maybe "Customize"?) -> Look for an option similar to "automatically show download dialog"
Then the download should work again. Moreover IE does not seem to have a problem with files that it can embed in the browser, like PDF files when the PDF plug-in is present in the browser or MS Office files when Office is installed.

The option of lowering the security options was no option for me because i can't control this and can't expect the user to do this, so i came up with a neat solution.

To describe it in a few sentences: when a user sessions starts (in the ApplicationWorkbenchWindowAdvisor#preWindowOpen() method) i create a simple shell with a single browser widget in it. This shell is hidden behind the main application shell so the user never sees it. When i want to send a download, i access the browser widget in the shell and call the Browser#setUrl() method with the URL to my file servicehandler. This causes the download dialog to show and thus allows *seamless* download of files. No external browser or pop-ups required! However, the problem with the IE download warning remains, but this time the user can click on the warning bar in the IE and allow the download. But be careful! IE restarts the session after doing this! The application restarts and the user has to click the download link again, now the IE will allow the download. Very ugly! But i don't see how to bypass this.
There are other tripwires. You need to take very good care on the header (and content-type) that you send along with your download. Among other stuff, the "Context-Disposition" must be "attachment;filename=..." with a filename provided. Otherwise you may risk that the downloaded file will get displayed in this hidden browser widget, and that would not be good ;).

However, this mechanism works very nice with FF and Chrome. I did this research in half a day, so i could not test it to the full extend yet, so anyone else may have suggestions or improvements??

What we learn again is that IE is simply a big piece of frakkin' sh*t ;). A nightmare for every web developer. Unfortunately, we often don't have the luxury to choose the end-user browser, especially in enterprise environments. I think we have to keep "working-around" IE ;)).

HTH,
-ben



Am 10.11.2010 15:17, schrieb Patrick:
> Le 08/11/2010 11:43, Patrick a écrit :
>> Hello,
>> I generate a file dynamically with a IServiceHandler and I use
>> ExternalBrowser for the download.
>> It works with Firefox, Chrome, and others, except Internet Explorer.
>> With IE (v8.0) a blank window seems to flicker briefly, but no download
>> happens.
>
> Am I the only one having this problem?
> Here is my code. Any help is welcome. Thank you.
>
> public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
>
> private IAction action;
>
> public static final String serviceHandlerId = "download";
>
> static {
> IServiceManager manager = RWT.getServiceManager ();
> IServiceHandler handler = new DownloadHandler ();
> manager.registerServiceHandler (serviceHandlerId, handler);
> }
>
> public ApplicationActionBarAdvisor (IActionBarConfigurer configurer) {
> super (configurer);
> }
>
> protected void makeActions (IWorkbenchWindow window) {
> action = new DownloadAction ();
> }
>
> protected void fillMenuBar (IMenuManager menuBar) {
> MenuManager menu = new MenuManager ("File");
> menu.add (action);
> menuBar.add (menu);
> }
>
> private static class DownloadAction extends Action {
> public DownloadAction () {
> setId (DownloadAction.class.getSimpleName ());
> setText ("Download");
> }
> public void run () {
> StringBuilder url = new StringBuilder ();
> url.append (RWT.getRequest ().getContextPath ());
> url.append (RWT.getRequest ().getServletPath ());
> url.append ("?");
> url.append (IServiceHandler.REQUEST_PARAM);
> url.append ("=");
> url.append (serviceHandlerId);
> ExternalBrowser.open ("_blank",
> RWT.getResponse ().encodeURL (url.toString ()), 0);
> }
> }
>
> private static class DownloadHandler implements IServiceHandler {
> public void service () throws IOException, ServletException {
> HttpServletResponse response = RWT.getResponse ();
> response.setContentType ("text/csv");
> response.setHeader ("Content-Disposition",
> "attachment; filename=\"test.csv\"");
> response.getOutputStream ().print ("a,1\n");
> response.getOutputStream ().print ("b,2\n");
> response.flushBuffer ();
> }
> }
> }
Re: Download does not work in IE [message #643743 is a reply to message #643718] Wed, 08 December 2010 06:48 Go to previous message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Ben, Patrick,
without testing myself you can give a try to download widget provided by
Stefan. See:
331157: Provide download widget
https://bugs.eclipse.org/bugs/show_bug.cgi?id=331157
HTH,
Ivan

On 08.12.2010 2:23 AM, Benjamin Wolff wrote:
> Hi,
>
> today i also became aware of this problem with the (damned) IE 8.
> The problem is, that the default security options of the IE don't generally allow a download. Instead, a warning at the top of the browser appears and you have to allow it manually (similar to the pop-up blocker). That's why the external browser window is closed immediately. One solution would be to lower the security restrictions in the IE: Options -> Security -> "Anpassen" (i don't know what it is called in the english version, maybe "Customize"?) -> Look for an option similar to "automatically show download dialog"
> Then the download should work again. Moreover IE does not seem to have a problem with files that it can embed in the browser, like PDF files when the PDF plug-in is present in the browser or MS Office files when Office is installed.
>
> The option of lowering the security options was no option for me because i can't control this and can't expect the user to do this, so i came up with a neat solution.
>
> To describe it in a few sentences: when a user sessions starts (in the ApplicationWorkbenchWindowAdvisor#preWindowOpen() method) i create a simple shell with a single browser widget in it. This shell is hidden behind the main application shell so the user never sees it. When i want to send a download, i access the browser widget in the shell and call the Browser#setUrl() method with the URL to my file servicehandler. This causes the download dialog to show and thus allows *seamless* download of files. No external browser or pop-ups required! However, the problem with the IE download warning remains, but this time the user can click on the warning bar in the IE and allow the download. But be careful! IE restarts the session after doing this! The application restarts and the user has to click the download link again, now the IE will allow the download. Very ugly! But i don't see how to bypass this.
> There are other tripwires. You need to take very good care on the header (and content-type) that you send along with your download. Among other stuff, the "Context-Disposition" must be "attachment;filename=..." with a filename provided. Otherwise you may risk that the downloaded file will get displayed in this hidden browser widget, and that would not be good ;).
>
> However, this mechanism works very nice with FF and Chrome. I did this research in half a day, so i could not test it to the full extend yet, so anyone else may have suggestions or improvements??
>
> What we learn again is that IE is simply a big piece of frakkin' sh*t ;). A nightmare for every web developer. Unfortunately, we often don't have the luxury to choose the end-user browser, especially in enterprise environments. I think we have to keep "working-around" IE ;)).
>
> HTH,
> -ben
>
>
>
> Am 10.11.2010 15:17, schrieb Patrick:
>> Le 08/11/2010 11:43, Patrick a écrit :
>>> Hello,
>>> I generate a file dynamically with a IServiceHandler and I use
>>> ExternalBrowser for the download.
>>> It works with Firefox, Chrome, and others, except Internet Explorer.
>>> With IE (v8.0) a blank window seems to flicker briefly, but no download
>>> happens.
>> Am I the only one having this problem?
>> Here is my code. Any help is welcome. Thank you.
>>
>> public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
>>
>> private IAction action;
>>
>> public static final String serviceHandlerId = "download";
>>
>> static {
>> IServiceManager manager = RWT.getServiceManager ();
>> IServiceHandler handler = new DownloadHandler ();
>> manager.registerServiceHandler (serviceHandlerId, handler);
>> }
>>
>> public ApplicationActionBarAdvisor (IActionBarConfigurer configurer) {
>> super (configurer);
>> }
>>
>> protected void makeActions (IWorkbenchWindow window) {
>> action = new DownloadAction ();
>> }
>>
>> protected void fillMenuBar (IMenuManager menuBar) {
>> MenuManager menu = new MenuManager ("File");
>> menu.add (action);
>> menuBar.add (menu);
>> }
>>
>> private static class DownloadAction extends Action {
>> public DownloadAction () {
>> setId (DownloadAction.class.getSimpleName ());
>> setText ("Download");
>> }
>> public void run () {
>> StringBuilder url = new StringBuilder ();
>> url.append (RWT.getRequest ().getContextPath ());
>> url.append (RWT.getRequest ().getServletPath ());
>> url.append ("?");
>> url.append (IServiceHandler.REQUEST_PARAM);
>> url.append ("=");
>> url.append (serviceHandlerId);
>> ExternalBrowser.open ("_blank",
>> RWT.getResponse ().encodeURL (url.toString ()), 0);
>> }
>> }
>>
>> private static class DownloadHandler implements IServiceHandler {
>> public void service () throws IOException, ServletException {
>> HttpServletResponse response = RWT.getResponse ();
>> response.setContentType ("text/csv");
>> response.setHeader ("Content-Disposition",
>> "attachment; filename=\"test.csv\"");
>> response.getOutputStream ().print ("a,1\n");
>> response.getOutputStream ().print ("b,2\n");
>> response.flushBuffer ();
>> }
>> }
>> }
Previous Topic:Splash Screen
Next Topic:Javascript Error, Upload, View
Goto Forum:
  


Current Time: Wed Apr 24 22:53:15 GMT 2024

Powered by FUDForum. Page generated in 0.03716 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top