开发者

GWT Frame not working in Mozilla Firefox or in Google chrome, but working fine in IE

开发者 https://www.devze.com 2023-02-09 06:35 出处:网络
I am trying to download a file from server. The normal GWT RPC call doesnot allow me to do that, and hence I wrote a servlet to do that job for me. From the client side, I am creating a Frame object,

I am trying to download a file from server. The normal GWT RPC call doesnot allow me to do that, and hence I wrote a servlet to do that job for me. From the client side, I am creating a Frame object, and I set the servlet URL in it, and add that frame Object in my root panel. When I execute this in IE, a window pops up asking for Save/Open file. But when I execute the same in a Firefox or a Google Chrome browser, nothing is happing. I am not getting any request on my servlet/server side. Here is a slice of the code :-

String servletUrl = "http://localhost:13080/Browser/ui/dataExportServlet?level=ZERO开发者_开发问答";

          Frame frame = new Frame(servletUrl);
    frame.setVisible(false);
    RootPanel.get().add(frame);

So, can someone please help me out.


This might be related to same origin policy. Are both servlet and webapp running on port 13080? If they differ, SOP might fail this. If I understand correctly, IE has a more relaxed policy so it might work there but not in chrome.

See http://en.wikipedia.org/wiki/Same_origin_policy and Can I disable SOP (Same Origin Policy) on any browser for development?


In Chrome, you can use the Developer Tools (CTRL + SHIFT + I) to check if the IFrame is being added to the HTML, and if the frame's source is being set properly. You should also be able to see what content has been loaded into the iframe.

Alternately, set a breakpoint in your servlet to see if the iframe is being hit at all from Chrome.


I got the solution for this issue. I removed the frames and added the following code :-

com.google.gwt.user.client.Window.open(url, "CSVDownload", "");

Now, this opens a new browser window, and then I get the pop-up to open/save the server side file in all 3 web-browsers. (IE, Mozilla FireFox, Chrome).

Thanks a lot!!!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号