Avatar of clo1
clo1 asked on

Servlet, how to download file?

I have generate an excel file from my servlet, under my document root's download directory, but how do I prompt the IE / user to save this xls file when they click on the link which will launch my servlet call. Please help. Thanks !
Java EEJava

Avatar of undefined
Last Comment
jmarrara

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
CEHJ

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Mayank S

Does your Servlet display something on the browser? You can have a hyper-link to the excel-file there. When the user clicks on it, it will prompt for download.
ASKER
clo1

Thanks CEHJ, it work perfectly in my OWN development environemnt, which is WinXP + Tomcat 5.0. But once I have uploaded to my production server (RedHat 9.0 + Tomcat 4.1.27), it does not success anymore. Even I have preset the filename for it, it doesn't allow me to download it. Any ideas? Please help. Thanks a lot !
CEHJ

What IS happening exactly?
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ASKER
clo1

It can prompt to save the file, but it is not the filename I preset from the servlet, it just prompt out another html page's name. And once I click on it, it gives me error message said it cannot be download, etc.... Please help. Thanks !
CEHJ

Have you followed the example in that article exactly?
SOLUTION
Mayank S

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Mayank S

>> it is not the filename I preset from the servlet

What file-name does it show and what file-name do you give in the Servlet? I guess it should show the original file-name.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Mayank S

Ok with me.
jmarrara

It worked fine to me.