file download option in GWT

1,036 views
Skip to first unread message

sathya

unread,
Sep 16, 2009, 3:16:21 AM9/16/09
to Google Web Toolkit
I am having problem in GWT 1.7.

In my application, I need to download file from server to client. So I
am directly using file path in window.open as shown below

Window.open(“d:\result.xls”,"_self","");

This opens in Firefox as expected however this doesn’t work with IE7.

Please let me know if there is any workaround to do this.

I need this very urgently. Please help me out in resolving this.

Ian Bambury

unread,
Sep 16, 2009, 7:00:28 AM9/16/09
to google-we...@googlegroups.com
Well, first off, it's probably not happy that there is a carriage return in the file name, and even if it ignores that, the file name ('d:esults.xls') probably doesn't exist.

Ian Bambury

unread,
Sep 16, 2009, 7:02:19 AM9/16/09
to google-we...@googlegroups.com
And even if there just happens to be a file named like that, your popup will probably be blocked.

sathya

unread,
Sep 16, 2009, 7:14:53 AM9/16/09
to Google Web Toolkit
Hi Bambury,
Can you help me in implementing this. My scenario is, I have
file on server disk. When ever client requests for it (when ever he
presses download button), file should get downloaded to client. Can
you tell me how can I implement this.

Ian Bambury

unread,
Sep 16, 2009, 9:39:27 AM9/16/09
to google-we...@googlegroups.com
The simplest way is just to put an anchor on the page called 'Download' but, depending on how the browser is set up, the browser may open it rather than download it which may not be what you want. It *is* however, what the user set up (or got lumbered with) as the default.

Anything more than that requires that you do things on the server, and that a) depends what you are using on the server, and b) is more appropriate on a Java or PHP (or whatever) forum since GWT is just client-side.

sathya

unread,
Sep 17, 2009, 1:55:21 AM9/17/09
to Google Web Toolkit
Hi Lan,
I am using below HTML link instead of window. Open ().I am facing
same problem.

When I click on link, download is successful with firefox.However this
link is not working in IE.When I click on link in IE, it says page
error (left bottom).Please help me in fixing this.

HTML link = new HTML("<a href=\"d:/nas/local/results/xml_5.6_46.2.xls
\">Download Report</a>");
full_report.add(link);



On Sep 16, 6:39 pm, Ian Bambury <ianbamb...@gmail.com> wrote:
> The simplest way is just to put an anchor on the page called 'Download' but,
> depending on how the browser is set up, the browser may open it rather than
> download it which may not be what you want. It *is* however, what the user
> set up (or got lumbered with) as the default.
> Anything more than that requires that you do things on the server, and that
> a) depends what you are using on the server, and b) is more appropriate on a
> Java or PHP (or whatever) forum since GWT is just client-side.
>
> Ian
>
> http://examples.roughian.com
>
> 2009/9/16 sathya <sathyavik...@gmail.com>
>
>
>
>
>
> > Hi Bambury,
> >       Can you help me in implementing this. My scenario is, I have
> > file on server disk. When ever client requests for it (when ever he
> > presses download button), file should get downloaded to client. Can
> > you tell me how can I implement this.
>
> > On Sep 16, 4:02 pm, Ian Bambury <ianbamb...@gmail.com> wrote:
> > > And even if there just happens to be a file named like that, your popup
> > will
> > > probably be blocked.- Hide quoted text -
>
> - Show quoted text -

Ian Bambury

unread,
Sep 17, 2009, 7:01:05 AM9/17/09
to google-we...@googlegroups.com
What error is it reporting?

sathya

unread,
Sep 18, 2009, 7:25:00 AM9/18/09
to Google Web Toolkit
Hi Lan,
Whenever I click on link,Nothing seems to work.I get error at
left bottom corner of IE saying access denied with script path.
I am not sure how to attach screen short here.So sending screen short
to your mail.




On Sep 17, 4:01 pm, Ian Bambury <ianbamb...@gmail.com> wrote:
> What error is it reporting?
> Ian
>
> http://examples.roughian.com
>
> 2009/9/17 sathya <sathyavik...@gmail.com>
> > > - Show quoted text -- Hide quoted text -

Ian Bambury

unread,
Sep 18, 2009, 7:49:18 AM9/18/09
to google-we...@googlegroups.com
Hi Sathya,

I'm not sure what you are doing is what you really want.

<a href=\"d:/nas/local/results/xml_5.6_46.2.xls\">Download Report</a>

is pointing to a file on the client's machine - is it likely to be there? And if it is there, why do they need to download it from their own machine?

I think you need a relative path to somewhere in the document root of your server or a subdirectory of it.

Ian (not Lan)

http://examples.roughian.com


2009/9/18 sathya <sathya...@gmail.com>

sathya

unread,
Sep 19, 2009, 9:55:11 PM9/19/09
to Google Web Toolkit
Hi Ian,
I am developing this application on my system and running it
IP "localhost:8080".
So tomcat server is setup on my same system where i am testing or
opening this page. So path I have given is D:\ drive(so D:\ acts as
server disk and also client disk).Problem is, it works with FF but
facing problem with only IE

If you are not able to get what I am writing, Just give me sample
example code to do the following task.

--> whenever i click download link, file on server should get
downloaded from server to client.(File is placed on server disk at
specific location).But this should work in IE also without any
problem.

Can you please more details of statement "I think you need a relative
path to somewhere in the document root of your
server or a subdirectory of it. "






On Sep 18, 4:49 am, Ian Bambury <ianbamb...@gmail.com> wrote:
> Hi Sathya,
> I'm not sure what you are doing is what you really want.
>
> <a href=\"d:/nas/local/results/xml_5.6_46.2.xls\">Download Report</a>
> is pointing to a file on the client's machine - is it likely to be there?
> And if it is there, why do they need to download it from their own machine?
>
> I think you need a relative path to somewhere in the document root of your
> server or a subdirectory of it.
>
> Ian (not Lan)
>
> http://examples.roughian.com
>
> 2009/9/18 sathya <sathyavik...@gmail.com>

Ian Bambury

unread,
Sep 19, 2009, 10:28:55 PM9/19/09
to google-we...@googlegroups.com
Put the file in the same place as your index.htm or, say, in a subdirectory called /results/

Don't use the disk letter, just use something like 

href="results/xml_5.6_46.2.xls"

sathya

unread,
Sep 21, 2009, 12:35:22 AM9/21/09
to Google Web Toolkit
Hi Ian,
Idea of getting file from href="/results/xml_5.6_46.2.xls" works
for me now. (Thanks so much for giving this IDEA).

However what I was doing before was, depending on user input,I will
dynamically generate these reports and save them on server disk and
when ever user clicks on link,File is downloaded with HTML link = new
HTML("<a href=\"d:/nas/local/results/xml_5.6_46.2.xls \">Download
Report</a>"); (which had issue and is resolved now with your IDEA of
keeping file in href="/results/xml_5.6_46.2.xls" ).

Now my problem is,I am not able to generate reports and save them at "/
results/" location.

I am using below code in my java program with try catch block to save
file.However file is not getting generated/saved.(even I am not
getting any exceptions)

FileOutputStream fileOut = new FileOutputStream("/reports/
xml_5.6_46.2.xls");
wb.write(fileOut);
fileOut.close();

Am I doing anything wrong in giving paths. (This was working fine when
I give disk drive eg: d:/reports/xml_5.6_46.2.xls).


On Sep 20, 7:28 am, Ian Bambury <ianbamb...@gmail.com> wrote:
> Put the file in the same place as your index.htm or, say, in a subdirectory
> called /results/
> Don't use the disk letter, just use something like
>
> href="results/xml_5.6_46.2.xls"
>
> Ian
>
> http://examples.roughian.com
>
> 2009/9/20 sathya <sathyavik...@gmail.com>

Ian Bambury

unread,
Sep 21, 2009, 6:21:29 AM9/21/09
to google-we...@googlegroups.com
When you create the file, you can use an absolute path (with a drive letter) to where the link is picking it up with the relative path.

sathya

unread,
Sep 21, 2009, 8:22:36 AM9/21/09
to Google Web Toolkit
Hi Ian,
I am not able to relate absolute path and relative path.

Can you give example of both absolute path and its equivalent relative
path whih I can use it in my code.

sathya

unread,
Sep 21, 2009, 8:26:56 AM9/21/09
to Google Web Toolkit

for eg, if d:/nas/local/results/xml_5.6_46.2.xls is absolute path,
Then what will equivalent relative path that I can use in my code to
where the link can pick it up.

On Sep 21, 5:22 pm, sathya <sathyavik...@gmail.com> wrote:
> Hi Ian,
>          I am not able to relate absolute path and relative path.
>
> Can you give example of both absolute path and its equivalent relative
> path whih I can use it in my code.
>
> On Sep 21, 3:21 pm, Ian Bambury <ianbamb...@gmail.com> wrote:
>
>
>
> > When you create thefile, you can use an absolute path (with a drive letter)
> > to where the link is picking it up with the relative path.
> > Ian
>
> >http://examples.roughian.com- Hide quoted text -

Ian Bambury

unread,
Sep 21, 2009, 9:13:35 AM9/21/09
to google-we...@googlegroups.com

sathya

unread,
Sep 23, 2009, 11:46:48 PM9/23/09
to Google Web Toolkit
Hi Ian,
Thanks very much for your IDEA.It worked for me and I am
able to proceed with next step.

On Sep 21, 6:13 pm, Ian Bambury <ianbamb...@gmail.com> wrote:
> http://en.wikipedia.org/wiki/Path_(computing)<http://en.wikipedia.org/wiki/Path_(computing)>
> Ian
>
> http://examples.roughian.com
>
> 2009/9/21 sathya <sathyavik...@gmail.com>
>
>
>
>
>
> > for eg, if d:/nas/local/results/xml_5.6_46.2.xls is absolute path,
> > Then what will equivalent relative path that I can use in my code to
> > where the link can pick it up.
>
> > On Sep 21, 5:22 pm, sathya <sathyavik...@gmail.com> wrote:
> > > Hi Ian,
> > >          I am not able to relate absolute path and relative path.
>
> > > Can you give example of both absolute path and its equivalent relative
> > > path whih I can use it in my code.
>
> > > On Sep 21, 3:21 pm, Ian Bambury <ianbamb...@gmail.com> wrote:
>
> > > > When you create thefile, you can use an absolute path (with a drive
> > letter)
> > > > to where the link is picking it up with the relative path.
> > > > Ian
>
> > > >http://examples.roughian.com-Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
Reply all
Reply to author
Forward
0 new messages