Oracle® interMedia Java Classes Reference 10g Release 1 (10.1) Part Number B10830-01 |
|
|
View PDF |
This section presents reference information on the methods of the oracle.ord.im.OrdHttpJspResponseHandler class.
The OrdHttpJspResponseHandler class facilitates the retrieval of media data from Oracle Database, and its delivery to a browser or another HTTP client from a JSP page.
This class inherits the DEFAULT_BUFFER_SIZE field from the OrdHttpResponseHandler class.
An Important Note on JSP Engines
JSP engines are not required to support access to the servlet binary output stream. Therefore, not all JSP engines support the delivery of media data using the OrdHttpJspResponseHandler class.All media data stored in the database using the interMedia types, including text documents stored using the OrdDoc type, is stored using a binary LOB data type. Media data stored internally in the database is stored using a BLOB. Media data stored in an operating system file outside the database is stored using a BFILE. Therefore, all media data is delivered to the browser through the servlet binary output stream, using the ServletOutputStream class.All the send methods in the OrdHttpJspResponseHandler class mirror the initial processing of the jsp:forward tag. Specifically, these send methods call the JspWriter clear( ) method to clear the output buffer of the page prior to obtaining the binary output stream. However, JSP engines are not required to support a call to the ServletResponse.getOutputStream method from within a JSP page. A JSP engine that does not support this typically throws an IllegalStateException error from the getOutputStream method. However, the exact behavior is implementation-specific. If your JSP engine does not support access to the binary output stream from within a JSP page, then you must use a servlet to deliver media data. For example, perform one of the following operations:
Use the jsp:forward tag to forward a multimedia retrieval request to a servlet.
Construct multimedia retrieval URLs to retrieve the data directly from a servlet.
An Important Note on Return Statements
When delivering media data from a JSP page, a return statement is always required following a call to any of the send methods of the OrdHttpJspResponseHandler class. The return statement is necessary to ensure that no other data is written to the output stream of the JSP page following the media data.An if ( true ) { ... return; }
construct may be used to avoid the "statement not reachable" error that may result from the presence of additional code, generated by the JSP engine, at the end of a compiled page. This construct, which mirrors exactly the code produced by some JSP engines to handle the <jsp:forward ... >
directive, is shown in the example provided later in this section.
Note: An interMedia Java object, such as an OrdImage object, is not dependent on the JDBC statement or result set from which it was obtained. However, an interMedia Java object is dependent on the JDBC connection it is using and on which the SQL statement was executed or from which the result set was obtained. Therefore, having obtained an interMedia Java object from the database, an application must not release the JDBC connection before delivering the media data to the browser. |
All the send methods in this class call the JspWriter clear( ) method to clear the page's output buffer prior to delivering the media. Therefore, the page must use the buffered output model, which is the default.
The following example demonstrates how to use the OrdHttpJspResponseHandler class to retrieve an image from the database and deliver it to a browser. The return statement ensures that the trailing newline characters following the final end tag (represented by a percent mark and right-angle bracket, or %>
) are not transmitted to the browser as part of 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.
<%@ 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; } %>
Format
public OrdHttpJspResponseHandler( )
Description
Creates an OrdHttpJspResponseHandler object to handle the response to a multimedia retrieval request. The application must subsequently specify the PageContext object by calling the setPageContext( ) method.
The default constructor is typically invoked implicitly when the OrdHttpJspResponseHandler class is used as a JavaBean.
Parameters
None.
Return Value
None.
Exceptions
None.
Examples
None.
Format
public OrdHttpJspResponseHandler(javax.servlet.jsp.PageContext pageContext)
Description
Creates an OrdHttpJspResponseHandler object to handle the response to a multimedia retrieval request, and specifies the PageContext object for the response handler.
Parameters
An object of type PageContext.
Return Value
None.
Exceptions
None.
Examples
None.
Format
public void sendAudio(oracle.ord.im.OrdAudio media)
Description
Retrieves an audio clip from an OrdAudio 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 output buffer of the page prior to delivering the audio clip. Therefore, the page must use the buffered output model, which is the default.
This method extends the OrdHttpResponseHandler sendAudio(OrdAudio) method. See sendAudio(OrdAudio) in OrdHttpResponseHandler Class for information about this method in the base class.
Parameters
An object of type oracle.ord.im.OrdAudio.
Return Value
This method overrides the sendAudio(OrdAudio) method in class OrdHttpResponseHandler.
Exceptions
java.lang.IllegalStateException
This exception is thrown if PageContext has not been specified.
OrdHttpResponseException
This exception is thrown if the source type is not recognized.
javax.servlet.ServletException
This exception is thrown if an error occurs accessing the binary output stream.
java.sql.SQLException
This exception is thrown if an error occurs obtaining an InputStream object to read the media data.
java.io.IOException
This exception is thrown if an error occurs reading the media data.
Examples
None.
Format
public void sendDoc(oracle.ord.im.OrdDoc media)
Description
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 output buffer of the page prior to delivering the media. Therefore, the page must use the buffered output model, which is the default.
This method extends the OrdHttpResponseHandler sendDoc(OrdDoc) method. See sendDoc(OrdDoc) in OrdHttpResponseHandler Class for information about this method in the base class.
Parameters
An object of type oracle.ord.im.OrdDoc.
Return Value
This method overrides the sendDoc(OrdDoc) method in class OrdHttpResponseHandler.
Exceptions
java.lang.IllegalStateException
This exception is thrown if PageContext has not been specified.
OrdHttpResponseException
This exception is thrown if the source type is not recognized.
javax.servlet.ServletException
This exception is thrown if an error occurs accessing the binary output stream.
java.sql.SQLException
This exception is thrown if an error occurs obtaining an InputStream object to read the media data.
java.io.IOException
This exception is thrown if an error occurs reading the media data.
Examples
None.
Format
public void sendImage(oracle.ord.im.OrdImage media)
Description
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 output buffer of the page prior to delivering the media. Therefore, the page must use the buffered output model, which is the default.
This method extends the OrdHttpResponseHandler sendImage(OrdImage) method. See sendImage(OrdImage) in OrdHttpResponseHandler Class for information about this method in the base class.
Parameters
An object of type oracle.ord.im.OrdImage.
Return Value
This method overrides the sendImage(OrdImage) method in class OrdHttpResponseHandler.
Exceptions
java.lang.IllegalStateException
This exception is thrown if PageContext has not been specified.
OrdHttpResponseException
This exception is thrown if the source type is not recognized.
javax.servlet.ServletException
This exception is thrown if an error occurs accessing the binary output stream.
java.sql.SQLException
This exception is thrown if an error occurs obtaining an InputStream object to read the media data.
java.io.IOException
This exception is thrown if an error occurs reading the media data.
Examples
None.
Format
public void sendResponse(String contentType, int length, oracle.sql.BFILE bfile,
java.sql.Timestamp lastModified)
Description
Builds the 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 output buffer of the page prior to delivering the media. Therefore, the page must use the buffered output model, which is the default.
This method extends the OrdHttpResponseHandler sendResponse(String, int, BFILE, Timestamp) method. See sendResponse(String, int, BFILE, Timestamp) in OrdHttpResponseHandler Class for information about this method in the base class.
Parameters
A String that specifies the MIME type of the content.
An integer that specifies the length of the data.
An object of type oracle.sql.BFILE from which the media data is retrieved.
A java.sql.Timestamp object that specifies the date and time when the data was last modified, or null if no last modified date and time are available.
Return Value
This method overrides the sendResponse(String, int, BFILE, Timestamp) method in class OrdHttpResponseHandler.
Exceptions
java.lang.IllegalStateException
This exception is thrown if PageContext has not been specified.
javax.servlet.ServletException
This exception is thrown if an error occurs accessing the binary output stream.
java.sql.SQLException
This exception is thrown if an error occurs obtaining an InputStream object to read the media data.
java.io.IOException
This exception is thrown if an error occurs reading the media data.
java.lang.IllegalArgumentException
This exception is thrown if the length is negative.
Examples
None.
Format
public void sendResponse(String contentType, int length, oracle.sql.BLOB blob,
java.sql.Timestamp lastModified)
Description
Builds the 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 output buffer of the page prior to delivering the media. Therefore, the page must use the buffered output model, which is the default.
This method extends the OrdHttpResponseHandler.sendResponse(String, int, BLOB, Timestamp) method. See sendResponse(String, int, BLOB, Timestamp) in OrdHttpResponseHandler Class for information about this method in the base class.
Parameters
A String that specifies the MIME type of the content.
An integer that specifies the length of the data.
An object of type oracle.sql.BLOB from which the media data is retrieved.
A java.sql.Timestamp object that specifies the date and time when the data was last modified, or null if no last modified date and time are available.
Return Value
This method overrides the sendResponse(String, int, BLOB, Timestamp) method in class OrdHttpResponseHandler.
Exceptions
java.lang.IllegalStateException
This exception is thrown if PageContext has not been specified.
javax.servlet.ServletException
This exception is thrown if an error occurs accessing the binary output stream.
java.sql.SQLException
This exception is thrown if an error occurs obtaining an InputStream object to read the media data.
java.io.IOException
This exception is thrown if an error occurs reading the media data.
java.lang.IllegalArgumentException
This exception is thrown if the length is negative.
Examples
None.
Format
public void sendResponse(String contentType, int length, java.io.InputStream in,
java.sql.Timestamp lastModified)
Description
Builds the HTTP response header, then retrieves the contents of the InputStream 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 output buffer of the page prior to delivering the media. Therefore, the page must use the buffered output model, which is the default.
This method extends the OrdHttpResponseHandler sendResponse(String, int, InputStream, Timestamp) method. See sendResponse(String, int, InputStream, Timestamp) in OrdHttpResponseHandler Class for information about this method in the base class.
Parameters
A String that specifies the MIME type of the content.
An integer that specifies the length of the data.
An InputStream object from which the media data is retrieved.
A java.sql.Timestamp object that specifies the date and time when the data was last modified, or null if no last modified date and time are available.
Return Value
This method overrides the sendResponse(String, int, InputStream, Timestamp) method in class OrdHttpResponseHandler.
Exceptions
java.lang.IllegalStateException
This exception is thrown if PageContext has not been specified.
javax.servlet.ServletException
This exception is thrown if an error occurs accessing the binary output stream.
java.io.IOException
This exception is thrown if an error occurs reading the media data.
java.lang.IllegalArgumentException
This exception is thrown if the length is negative.
Examples
None.
Format
public void sendVideo(oracle.ord.im.OrdVideo media)
Description
Retrieves a video clip from an OrdVideo 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 output buffer of the page prior to delivering the video clip. Therefore, the page must use the buffered output model, which is the default.
This method extends the OrdHttpResponseHandler sendVideo(OrdVideo) method. See sendVideo(OrdVideo) in OrdHttpResponseHandler Class for information about this method in the base class.
Parameters
An object of type oracle.ord.im.OrdVideo.
Return Value
This method overrides the sendVideo(OrdVideo) method in class OrdHttpResponseHandler.
Exceptions
java.lang.IllegalStateException
This exception is thrown if PageContext has not been specified.
OrdHttpResponseException
This exception is thrown if the source type is not recognized.
javax.servlet.ServletException
This exception is thrown if an error occurs accessing the binary output stream.
java.sql.SQLException
This exception is thrown if an error occurs obtaining an InputStream object to read the media data.
java.io.IOException
This exception is thrown if an error occurs reading the media data.
Examples
None.
Format
public void setPageContext(javax.servlet.jsp.PageContext pageContext)
Description
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
An object of type PageContext.
Return Value
None.
Exceptions
None.
Examples
None.