// Set the filename, is used when the file will be saved (problem with mozilla)
response.addHeader( "Content-Disposition",
"attachment; filename=" + shortFileName);
// Constructing the multi part response to the client
MultipartResponse multipartresponse = new MultipartResponse(response);
// Is the convert type HTML?
if ( ( multipartrequest.getParameter( "converttype" ).equals(
"swriter: HTML (StarWriter)" ) )
|| ( multipartrequest.getParameter( "converttype" ).equals(
"scalc: HTML (StarCalc)" ) ) ) {
// Setting the content type of the response being sent to the client
// to text
multipartresponse.startResponse( "text/html" );
} else {
// Setting the content type of the response being sent to the client
// to application/octet-stream so that file will open a dialog box
// at the client in order to save the converted file
multipartresponse.startResponse( "application/octet-stream" );
}
// Pushing the converted file to the client
ServletUtils.returnFile( stringConvertedFile,
response.getOutputStream() );
// Finishing the multi part response
multipartresponse.finish();
// clean up the working directory
cleanupFile = new File(stringConvertedFile);
if ( cleanupFile.exists() )
cleanupFile.delete();