How do you set a response header to indicate the content should be downloaded as a file?
- response.setHeader("Content-Disposition", "attachment; filename=example.txt");
- response.setHeader("Content-Encoding", "gzip");
- response.setHeader("Content-Transfer-Encoding", "binary");
- response.setHeader("Content-Type", "application/octet-stream");
To indicate that the content should be downloaded as a file, you can use the response.setHeader("Content-Disposition", "attachment; filename=example.txt"); method.
Loading...
Related Quiz
- In distributed systems, what is a cache stampede and how is it typically mitigated?
- How would a filter log request information without altering the request itself?
- To improve scalability, servlets can delegate database reads to ________ instances.
- What is the impact of synchronization on servlet performance?
- What is the primary purpose of garbage collection in Java?