com.scooterframework.web.controller
Class ContentHandlerHelper

java.lang.Object
  extended by com.scooterframework.web.controller.ContentHandlerHelper

public class ContentHandlerHelper
extends java.lang.Object

ContentHandlerHelper provides helper methods for content handlers. The default MIME type for text data is text/plain, while application/octet-stream for binary data.


Constructor Summary
ContentHandlerHelper()
           
 
Method Summary
static void publish(javax.servlet.http.HttpServletResponse response, byte[] content, java.lang.String mimeType)
          Sends content bytes to the requestor.
static void publish(javax.servlet.http.HttpServletResponse response, java.io.File file, java.lang.String displayableName, java.lang.String mimeType, boolean forDownload)
          Sends a file to the requestor.
static void publish(javax.servlet.http.HttpServletResponse response, java.io.InputStream is, java.lang.String mimeType)
          Sends an input stream to the requestor.
static void publish(javax.servlet.http.HttpServletResponse response, java.lang.Object content, java.lang.String mimeType)
          Sends content to the requestor.
static void publish(javax.servlet.http.HttpServletResponse response, java.lang.String content, java.lang.String mimeType)
          Sends content string to the requestor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContentHandlerHelper

public ContentHandlerHelper()
Method Detail

publish

public static void publish(javax.servlet.http.HttpServletResponse response,
                           java.lang.Object content,
                           java.lang.String mimeType)
                    throws java.io.IOException,
                           javax.servlet.ServletException
Sends content to the requestor. This method delegates to other methods when the content is an instance of String, byte[], InputStream respectively. In all other cases, the content is sent as a string.

Parameters:
response - The HTTP response object.
content - The content to be sent.
mimeType - The content MIME type.
Throws:
java.io.IOException
javax.servlet.ServletException

publish

public static void publish(javax.servlet.http.HttpServletResponse response,
                           java.lang.String content,
                           java.lang.String mimeType)
                    throws java.io.IOException,
                           javax.servlet.ServletException
Sends content string to the requestor. Default mimeType is text/plain.

Parameters:
response - The HTTP response object.
content - The content to be sent.
mimeType - The content MIME type.
Throws:
java.io.IOException
javax.servlet.ServletException

publish

public static void publish(javax.servlet.http.HttpServletResponse response,
                           byte[] content,
                           java.lang.String mimeType)
                    throws java.io.IOException,
                           javax.servlet.ServletException
Sends content bytes to the requestor. Default mimeType is application/octet-stream.

Parameters:
response - The HTTP response object.
content - The content to be sent.
mimeType - The content MIME type.
Throws:
java.io.IOException
javax.servlet.ServletException

publish

public static void publish(javax.servlet.http.HttpServletResponse response,
                           java.io.InputStream is,
                           java.lang.String mimeType)
                    throws java.io.IOException,
                           javax.servlet.ServletException
Sends an input stream to the requestor.

Parameters:
response - The HTTP response object.
is - The input stream to be sent.
mimeType - The content MIME type.
Throws:
java.io.IOException
javax.servlet.ServletException

publish

public static void publish(javax.servlet.http.HttpServletResponse response,
                           java.io.File file,
                           java.lang.String displayableName,
                           java.lang.String mimeType,
                           boolean forDownload)
                    throws java.io.IOException,
                           javax.servlet.ServletException
Sends a file to the requestor.

Parameters:
response - The HTTP response object.
file - The file to be sent.
displayableName - The display name of the file in the download dialog.
mimeType - The content MIME type.
forDownload - indicates whether this is for file download or display.
Throws:
java.io.IOException
javax.servlet.ServletException