By Date: <-- -->
By Thread: <-- -->

Writing a text file back to browser from a servlet



I'm trying to do something that seems like it should be very easy, but can't get it to work: sending a .txt file back to the user's browser so they can save it to their local hard disk. I am having no trouble creating the file and writing it to a temporary place on the server, but can't figure out what I need to do so the users can save the result.

Right now, I'm using the following code excerpt:

fReader = new FileReader( fullFileName );
bReader = new BufferedReader( fReader );
oStream = response.getOutputStream();
while (( logString = bReader.readLine()) != null ) {
// I'm sure a println would also work, but this is what I happen to have right now
oStream.write(( logString + EddRcvr.newLineStr ).getBytes());
}
oStream.close();
bReader.close();
fReader.close();



And it *displays* just fine in the browser window, but when I try to save it (using firefox 1.5.x), the download windows says it completed successfully, but the file is never there when I try to look at it.


Any suggestions as to what I'm missing?

TIA!
Dave



---------------------------------------------------------------------
To start a new topic, e-mail: users (at) tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe (at) tomcat.apache.org
For additional commands, e-mail: users-help (at) tomcat.apache.org