hareendran dileep wrote:Karthick,
Whenever you do a response.setHeader, you are sending some instruction to the browser (which initiated the request). In this case with "Content-Disposition" you are advising the browser how to handle the content being streamed to it.
Ulf Dittmer's code says that the browser should treat the response body as an attachment and that it's name to be shown in the File Download dialog is "myFooBar.jar"
Hope this helps!
Kathleen Tillman wrote:I may sound like a dunce, but I'm not quite sure what you mean by "in class not in method main".
Does that mean I need to move it farther down or farther up? And wouldn't that screw up showing the total after the information has been entered? I'm really new to Java, so this may sound like a really dumb question, but I'm confused.
Thanks.
Ulf Dittmer wrote:The servlet should set the Content-Disposition header; something like this should do the trick:
response.setHeader("Content-Disposition", "attachment; filename=\"myFooBar.jar\"");
steve claflin wrote:The offset is the position to start WRITING in the destination array, not the location to read from in the source stream. The read starts at the current position in the input stream, which is whatever location you left off at from the previous read.
Vinoth Thirunavukarasu wrote:Its so simple
The only thing is we have to set context path in your Tomcat/conf/server.xml
<Context path=""
docBase="/SimpleWebApps"
reloadable="true" >
</Context>
William Brogden wrote:It has been a while but as I recall, you also need to set the content length header or the browser never decides that it has all the content. You can of course get the file length before you start if you open /graphs.pdf by means of a File instead of getting as stream.
Bill
Ulf Dittmer wrote:
Any exceptions in the log files?
You probably meant to say "is.read(bytes)" instead of "is.read()".
Mohamed Inayath wrote:Good.
But your earlier attachment wrt the calci.java says a package definition : classes.
This time I believe you have removed that.