my dog learned polymorphism
The moose likes Servlets and the fly likes Re: downloading from a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic

Re: downloading from a servlet

Adewale Adebusoye
Ranch Hand

Joined: Sep 28, 2005
Posts: 118
i included the servlet response headers:

response.setHeader("Content-Type", "text/plain");
response.setHeader("Content-Disposition", "attachment; filename=file.txt"));

the only thing that its not downloading my attached file, rather, its set the filename to null, and its downloading the dynamic html generated by my servlet into a file.

So am i supposed to actually code for the download itself?

Please reply

"Human beings can alter their lives by altering their state of mind" William James
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Please keep your question in one thread.
It gets confusing if it's spread out in multiple threads.

The original is here:

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: Re: downloading from a servlet
It's not a secret anymore!