Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Servlets
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Servlets
how content disposition works
shriram iyer
Ranch Hand
Posts: 43
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
import javax.servlet.*; import javax.servlet.http.*; public class SecondServlet extends HttpServlet { public void doGet(HttpServletRequest request , HttpServletResponse response) throws ServletException , IOException { File fileName= new File("c:\\abc.txt"); response.setContentType("application/x-download"); response.setHeader("Content-disposition", "attachment;filename=" +fileName.getName()); } }
When i run the above
servlet
file abc.txt is getting saved,but without content.how to download a file abc.txt along with its content.
thanks
Bear Bibeault
Sheriff
Posts: 67746
173
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Stream the contents to the response output stream.
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
making a download servlet to service download managers
download link in jsp ?
Should the download code be modified specially for office2003
How to Specify the dynamic name for setting a file for downloading?
Content-Disposition: Download file name problem
More...