Solved

Servlet, how to download file?

Posted on 2004-03-26
12
194 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 !
0
Comment
Question by:clo1
  • 4
  • 3
  • 2
  • +1
12 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 25 total points
ID: 10685622
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10685648
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
 
LVL 2

Author Comment

by:clo1
ID: 10693574
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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
LVL 86

Expert Comment

by:CEHJ
ID: 10696539
What IS happening exactly?
0
 
LVL 2

Author Comment

by:clo1
ID: 10697252
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 10698098
Have you followed the example in that article exactly?
0
 
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 25 total points
ID: 10698693
Just a thought. Have you set the MIME-type correctly?
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10698700
>> 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
 
LVL 30

Expert Comment

by:Mayank S
ID: 10857759
Ok with me.
0
 

Expert Comment

by:jmarrara
ID: 11731383
It worked fine to me.
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to increase Spring boot/Tomcat max file upload size 2 157
maven module vs maven project 3 47
Notify sent to other threads in Java 9 34
Java Eclipse Loop 3 21
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question