We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Servlet, how to download file?

clo1
clo1 asked
on
Medium Priority
216 Views
Last Modified: 2013-11-24
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 !
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2016
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Mayank SPrincipal Technologist
CERTIFIED EXPERT

Commented:
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.

Author

Commented:
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 !
CERTIFIED EXPERT
Top Expert 2016

Commented:
What IS happening exactly?

Author

Commented:
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 !
CERTIFIED EXPERT
Top Expert 2016

Commented:
Have you followed the example in that article exactly?
Mayank SPrincipal Technologist
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Mayank SPrincipal Technologist
CERTIFIED EXPERT

Commented:
>> 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.
Mayank SPrincipal Technologist
CERTIFIED EXPERT

Commented:
Ok with me.

Commented:
It worked fine to me.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.