Using JSP? Just place a HTML <a> element with a valid URL to the file in question to represent a download link. If the file isn´t exposed in public, let the URL point to a servlet which streams the file to the response.
Edit: the darn forum engine was parsing the <a> element in the message &%"#$ .. Disabling HTML in this message.
The code at its own makes also no sense. response.completeResponse?
I have edited now.
It's also possible to drive a screw using a hammer. Doesn't make it a good idea.
Yes, it is not good idea you already communicated in the thread. But each and every project has its own challenge and reasoning. There is no harm in giving possible ways.
“Any fool can write code that a computer can understand. Good programmers write code that humans can understand. ”<br>
-Martin Fowler
I see that the code snippet in question has been modified. It doesn't matter. Doing any Java in a JSP, especially something like this, is a bad, bad, and did I mention BAD idea. It will be fragile and error-prone. Just don't do it.
Venkat Sadasivam wrote:There is no harm in giving possible ways.
Showing code that demonstrates poor practices may lead people, especially novices, to think that such code is ok to emulate. You can expect that the more senior developers will point out when such code is posted.