2.17.2: 2011-06-17

net.sf.basedb.clients.web.util
Class ServletExportOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by net.sf.basedb.core.plugin.ExportOutputStream
          extended by net.sf.basedb.clients.web.util.ServletExportOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class ServletExportOutputStream
extends ExportOutputStream

An extension to the ExportOutputStream class which directs the output to the response stream of a HttpServletResponse object. This allows an export plugin to send data directly to the web browser without going throgh the BASE filesystem or temporary files on the disk.

Version:
2.2
Author:
nicklas
Last modified
$Date: 2008-09-15 11:18:48 +0200 (Mon, 15 Sep 2008) $

Field Summary
private  HttpServletResponse response
           
 
Constructor Summary
ServletExportOutputStream(HttpServletResponse response)
          Create a new servlet export stream.
 
Method Summary
 void setCharacterSet(String charset)
          Calls ServletResponse.setCharacterEncoding(String)
 void setContentLength(long contentLength)
          Calls ServletResponse.setContentLength(int)
 void setFilename(String filename)
          Calls HttpServletResponse.setHeader(java.lang.String, java.lang.String) with the following values: response.setHeader("Content-Disposition", "attachment;filename=<filename>"); If the filename contains unsafe characters it is URL encoded.
 void setMimeType(String mimeType)
          Calls ServletResponse.setContentType(String)
 
Methods inherited from class net.sf.basedb.core.plugin.ExportOutputStream
close, flush, getFile, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

response

private final HttpServletResponse response
Constructor Detail

ServletExportOutputStream

public ServletExportOutputStream(HttpServletResponse response)
                          throws IOException
Create a new servlet export stream.

Parameters:
response - The servlet response object
Throws:
IOException - If getting the output stream from the reponse fails.
Method Detail

setContentLength

public void setContentLength(long contentLength)
Calls ServletResponse.setContentLength(int)

Overrides:
setContentLength in class ExportOutputStream

setMimeType

public void setMimeType(String mimeType)
Calls ServletResponse.setContentType(String)

Overrides:
setMimeType in class ExportOutputStream

setCharacterSet

public void setCharacterSet(String charset)
Calls ServletResponse.setCharacterEncoding(String)

Overrides:
setCharacterSet in class ExportOutputStream
Since:
2.9

setFilename

public void setFilename(String filename)
Calls HttpServletResponse.setHeader(java.lang.String, java.lang.String) with the following values: response.setHeader("Content-Disposition", "attachment;filename=<filename>"); If the filename contains unsafe characters it is URL encoded.

Overrides:
setFilename in class ExportOutputStream

2.17.2: 2011-06-17