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 !
LVL 2
clo1Asked:
Who is Participating?
 
Mayank SAssociate Director - Product EngineeringCommented:
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.
0
 
clo1Author 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 !
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
CEHJCommented:
What IS happening exactly?
0
 
clo1Author 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 !
0
 
CEHJCommented:
Have you followed the example in that article exactly?
0
 
Mayank SAssociate Director - Product EngineeringCommented:
Just a thought. Have you set the MIME-type correctly?
0
 
Mayank SAssociate Director - Product EngineeringCommented:
>> 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.
0
 
Mayank SAssociate Director - Product EngineeringCommented:
Ok with me.
0
 
jmarraraCommented:
It worked fine to me.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.