interMedia BC4J Integration

oracle.ord.im
Class OrdHttpJspResponseHandler

java.lang.Object
  |
  +--oracle.ord.im.OrdHttpResponseHandler
        |
        +--oracle.ord.im.OrdHttpJspResponseHandler

public class OrdHttpJspResponseHandler
extends OrdHttpResponseHandler

The OrdHttpJspResponseHandler class facilitates the retrieval of multimedia data from an Oracle9i database and its delivery to a browser or other HTTP client from a JavaServer Page (JSP).

Important

Important

Note

The send methods in this class all call the JspWriter.clear method to clear the page's output buffer prior to delivering the image. Therefore, the page must use the buffered output model, which is the default.

The following example illustrates how to use the OrdHttpJspResponseHandler class to retrieve an image from a database and deliver it to a browser:

  <%@ page language="java" %>
  <%@ page import="OrdSamplePhotoAlbumBean" %>
  <%@ page import="oracle.ord.im.OrdHttpJspResponseHandler" %>

  <jsp:useBean id="photos" scope="page"
               class="OrdSamplePhotoAlbumBean"/>
  <jsp:useBean id="handler" scope="page"
               class="oracle.ord.im.OrdHttpJspResponseHandler"/>

  <%
    //
    // Select the entry from the table using the id request parameter,
    // then fetch the row.
    //
    photos.selectRowById( request.getParameter( "id" ) );
    if ( !photos.fetch() )
    {
      response.setStatus( response.SC_NOT_FOUND );
      return;
    }

    //
    // Set the page context for the retrieve request, then retrieve
    // the image from the database and deliver it to the browser. The
    // getImage() method returns an object of type oracle.ord.im.OrdImage.
    //
    if ( true )
    {
        handler.setPageContext( pageContext );
        handler.sendImage( photos.getImage() );
        return;
    }
  %>
In the preceding example, the return statement ensures that the trailing new-line characters following the final end tag (%>) are not transmitted to the browser following the image.

The if ( true ) { ... return; } construct is used to avoid the "statement not reachable" error that would otherwise be produced by this example due to the additional statements, generated by the JSP engine, at the end of the compiled page.


Fields inherited from class oracle.ord.im.OrdHttpResponseHandler
DEFAULT_BUFFER_SIZE
 
Constructor Summary
OrdHttpJspResponseHandler()
          Creates an OrdHttpJspResponseHandler object to handle the response to a multimedia retrieval request.
OrdHttpJspResponseHandler(javax.servlet.jsp.PageContext pageContext)
          Creates an OrdHttpJspResponseHandler object to handle the response to a multimedia retrieval request and specifies the PageContext object for the response handler.
 
Method Summary
TypeMethod
 void sendAudio(OrdAudio audio)
          Retrieves an audio clip from an OrdAudio object and delivers it to browser.
 void sendDoc(OrdDoc doc)
          Retrieves media data from an OrdDoc object and delivers it to the browser.
 void sendImage(OrdImage image)
          Retrieves an image from an OrdImage object and delivers it to the browser.
 void sendResponse(java.lang.String contentType, int length, oracle.sql.BFILE bfile, java.sql.Timestamp lastModified)
          Builds an HTTP response header, then retrieves the contents of the BFILE from the database and delivers it to the browser.
 void sendResponse(java.lang.String contentType, int length, oracle.sql.BLOB blob, java.sql.Timestamp lastModified)
          Builds an HTTP response header, then retrieves the contents of the BLOB from the database and delivers it to the browser.
 void sendResponse(java.lang.String contentType, int length, java.io.InputStream in, java.sql.Timestamp lastModified)
          Builds an HTTP response header, then retrieves the contents from the InputStream and delivers it to the browser.
 void sendVideo(OrdVideo video)
          Retrieves a video clip from an OrdVideo object and delivers it to browser.
 void setPageContext(javax.servlet.jsp.PageContext pageContext)
          Specifies the PageContext object for this response handler.
 
Methods inherited from class oracle.ord.im.OrdHttpResponseHandler
sendResponseBody, sendResponseBody, sendResponseBody, setBufferSize, setServletRequest, setServletResponse
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OrdHttpJspResponseHandler

public OrdHttpJspResponseHandler()
Creates an OrdHttpJspResponseHandler object to handle the response to a multimedia retrieval request. The application must subsequently specify the PageContext object by calling setPageContext().

OrdHttpJspResponseHandler

public OrdHttpJspResponseHandler(javax.servlet.jsp.PageContext pageContext)
Creates an OrdHttpJspResponseHandler object to handle the response to a multimedia retrieval request and specifies the PageContext object for the response handler.
Parameters:
pageContext - an object of type PageContext.
Method Detail

setPageContext

public void setPageContext(javax.servlet.jsp.PageContext pageContext)
Specifies the PageContext object for this response handler. You must call this method before calling any of the send methods if you did not specify the PageContext object in the constructor.
Parameters:
pageContext - an object of type PageContext.

sendImage

public void sendImage(OrdImage image)
               throws javax.servlet.ServletException,
                      java.sql.SQLException,
                      java.io.IOException
Retrieves an image from an OrdImage object and delivers it to the browser. This method supports browser content caching by supporting the If-Modified-Since and Last-Modified headers. This method calls the JspWriter.clear method to clear the page's output buffer prior to delivering the image. Therefore, the page must use the buffered output model, which is the default.
Overrides:
sendImage in class OrdHttpResponseHandler
Parameters:
image - an object of type oracle.ord.im.OrdImage.
Throws:
IllegalStateException - if PageContext has not been specified.
OrdHttpResponseException - if the source type is not recognized.
ServletException - if an error occurs accessing the binary output stream.
java.sql.SQLException - if an error occurs obtaining an InputStream to read the image data.
java.io.IOException - if an error occurs reading the image data.

sendAudio

public void sendAudio(OrdAudio audio)
               throws javax.servlet.ServletException,
                      java.sql.SQLException,
                      java.io.IOException
Retrieves an audio clip from an OrdAudio object and delivers it to browser. This method supports browser content caching by supporting the If-Modified-Since and Last-Modified headers. This method calls the JspWriter.clear method to clear the page's output buffer prior to delivering the audio clip. Therefore, the page must use the buffered output model, which is the default.
Overrides:
sendAudio in class OrdHttpResponseHandler
Parameters:
audio - an object of type oracle.ord.im.OrdAudio.
Throws:
IllegalStateException - if PageContext has not been specified.
OrdHttpResponseException - if the source type is not recognized.
ServletException - if an error occurs accessing the binary output stream.
java.sql.SQLException - if an error occurs obtaining an InputStream to read the audio data.
java.io.IOException - if an error occurs reading the audio data.

sendVideo

public void sendVideo(OrdVideo video)
               throws javax.servlet.ServletException,
                      java.sql.SQLException,
                      java.io.IOException
Retrieves a video clip from an OrdVideo object and delivers it to browser. This method supports browser content caching by supporting the If-Modified-Since and Last-Modified headers. This method calls the JspWriter.clear method to clear the page's output buffer prior to delivering the video clip. Therefore, the page must use the buffered output model, which is the default.
Overrides:
sendVideo in class OrdHttpResponseHandler
Parameters:
video - an object of type oracle.ord.im.OrdVideo.
Throws:
IllegalStateException - if PageContext has not been specified.
OrdHttpResponseException - if the source type is not recognized.
ServletException - if an error occurs accessing the binary output stream.
java.sql.SQLException - if an error occurs obtaining an InputStream to read the video data.
java.io.IOException - if an error occurs reading the video data.

sendDoc

public void sendDoc(OrdDoc doc)
             throws javax.servlet.ServletException,
                    java.sql.SQLException,
                    java.io.IOException
Retrieves media data from an OrdDoc object and delivers it to the browser. This method supports browser content caching by supporting the If-Modified-Since and Last-Modified headers. This method calls the JspWriter.clear method to clear the page's output buffer prior to delivering the image. Therefore, the page must use the buffered output model, which is the default.
Overrides:
sendDoc in class OrdHttpResponseHandler
Parameters:
doc - an object of type oracle.ord.im.OrdDoc.
Throws:
IllegalStateException - if PageContext has not been specified.
OrdHttpResponseException - if the source type is not recognized.
ServletException - if an error occurs accessing the binary output stream.
java.sql.SQLException - if an error occurs obtaining an InputStream to read the media data.
java.io.IOException - if an error occurs reading the media data.

sendResponse

public void sendResponse(java.lang.String contentType,
                         int length,
                         oracle.sql.BLOB blob,
                         java.sql.Timestamp lastModified)
                  throws javax.servlet.ServletException,
                         java.sql.SQLException,
                         java.io.IOException
Builds an HTTP response header, then retrieves the contents of the BLOB from the database and delivers it to the browser. This method supports browser content caching by supporting the If-Modified-Since and Last-Modified headers. This method calls the JspWriter.clear method to clear the page's output buffer prior to delivering the image. Therefore, the page must use the buffered output model, which is the default.
Overrides:
sendResponse in class OrdHttpResponseHandler
Parameters:
contentType - a String that specifies the content's MIME type.
length - an int that specifies the length of the data.
blob - an object of type oracle.sql.BLOB.
lastModified - a java.sql.Timestamp that specifies the date/time when the data was last modified, or null if no last modified date/time is available.
Throws:
IllegalStateException - if PageContext has not been specified.
ServletException - if an error occurs accessing the binary output stream.
java.sql.SQLException - if an error occurs obtaining an InputStream to read the multimedia data.
java.io.IOException - if an error occurs reading the multimedia data.
java.lang.IllegalArgumentException - if the length is negative.

sendResponse

public void sendResponse(java.lang.String contentType,
                         int length,
                         oracle.sql.BFILE bfile,
                         java.sql.Timestamp lastModified)
                  throws javax.servlet.ServletException,
                         java.sql.SQLException,
                         java.io.IOException
Builds an HTTP response header, then retrieves the contents of the BFILE from the database and delivers it to the browser. This method supports browser content caching by supporting the If-Modified-Since and Last-Modified headers. This method calls the JspWriter.clear method to clear the page's output buffer prior to delivering the image. Therefore, the page must use the buffered output model, which is the default.
Overrides:
sendResponse in class OrdHttpResponseHandler
Parameters:
contentType - a String that specifies the content's MIME type.
length - an integer that specifies the length of the data.
bfile - an object of type oracle.sql.BFILE.
lastModified - a java.sql.Timestamp that specifies the date/time when the data was last modified, or null if no last modified date/time is available.
Throws:
IllegalStateException - if PageContext has not been specified.
ServletException - if an error occurs accessing the binary output stream.
java.sql.SQLException - if an error occurs obtaining an InputStream to read the multimedia data.
java.io.IOException - if an error occurs reading the multimedia data.
java.lang.IllegalArgumentException - if the length is negative.

sendResponse

public void sendResponse(java.lang.String contentType,
                         int length,
                         java.io.InputStream in,
                         java.sql.Timestamp lastModified)
                  throws javax.servlet.ServletException,
                         java.io.IOException
Builds an HTTP response header, then retrieves the contents from the InputStream and delivers it to the browser. This method supports browser content caching by supporting the If-Modified-Since and Last-Modified headers. This method calls the JspWriter.clear method to clear the page's output buffer prior to delivering the image. Therefore, the page must use the buffered output model, which is the default.
Overrides:
sendResponse in class OrdHttpResponseHandler
Parameters:
contentType - a String that specifies the content's MIME type.
length - an integer that specifies the length of the data.
in - an InputStream from which the multimedia data is retrieved.
lastModified - a java.sql.Timestamp that specifies the date/time when the data was last modified, or null if no last modified date/time is available.
Throws:
IllegalStateException - if PageContext has not been specified.
ServletException - if an error occurs accessing the binary output stream.
java.io.IOException - if an error occurs reading the multimedia data.
java.lang.IllegalArgumentException - if the length is negative.

interMedia BC4J Integration