Skip Headers

Oracle® Application Server 10g Multimedia Tag Library for JSP User's Guide and Reference
10g (9.0.4)
Part No. B10445-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous Next  

4 Media Upload Reference Information

Oracle Application Server 10g Multimedia Tag Library for JSP ("Multimedia Tag Library") provides media upload tags that help multimedia applications to upload media data into the database. The media upload tags are as follows:

Media upload tags meet the following requirements:

Application developers must be able to specify the following information when attempting to upload media data:

4.1 Prerequisites

None.

4.2 Reference Information

This section presents reference information on the media upload tags that operate on interMedia objects.


storeMedia

Format

<ord:storeMedia conn = "<%= jspExpression %>"
table = "string | <%= jspExpression %>"
[ key = "string | <%= jspExpression %>" ]
[ keyColumn = "string | <%= jspExpression %>" ]
[ rowid = "string | <%= jspExpression %>" ]
mediaColumns = "values"
mediaParameters = "values"
[ otherColumns = "values" ]
[ otherValues = "<%= jspExpression %>" ]/>

where,

values = string | <%=jspExpression%> [, string | <%=jspExpression%>]...

Description

Operates within the body of the uploadFormData tag. The storeMedia tag implicitly uses the form-data object created by the uploadFormData tag through the mediaParameters attribute. This tag loads the uploaded media data from the HTML form into the OrdImage, OrdAudio, OrdVideo, or OrdDoc object in the specified table, row, and column in the database. If the specified row does not exist, a new row will be inserted and updated with the loaded data. The transaction commits automatically if autocommit is set to true in the database connection object. The mediaColumns and mediaParameters attributes allow multiple media data specified in an HTML form to be uploaded into multiple columns in a particular row. The otherColumns and otherValues attributes allow other columns of the table to be updated along with the media data.

After loading the media data in the database BLOB, the tag calls the setProperties( ) method to set the media properties within the object. If the media format is not recognized by interMedia, this tag sets the mimeType and length properties only.


Note:

In the case when the specified row does not exist and a new row is inserted into the table, any other columns in the table that are not specified in the mediaColumns and otherColumns attributes must allow the null value.

Parameters

conn

The JDBC connection (java.sql.Connection object) used to store the media data.

table

A String literal or expression that specifies the name of the table containing the media data.

key

A String literal or expression that specifies the key value to use to fetch the media. The table's primary key is used if the keyColumn attribute is not specified. If the table does not have a primary key, a key column name must be specified with the keyColumn attribute.

keyColumn

A String literal or expression that specifies the column to use to access the media.

rowid

A String literal or expression that indicates the ROWID of the media in the specified table. Specifying this attribute is the equivalent of specifying key="rowid-value" keyColumn="rowid".

mediaColumns

The names of the columns to be loaded with the uploaded media data.

mediaParameters

The names of the parameters used to upload the media data, as specified in the HTML form.

otherColumns

The names of the other columns to be updated or inserted in the table.

otherValues

The updated or inserted values of the other columns in the table that correspond to the otherColumns attribute. These values must be stored in a java.util.Vector object.

Exceptions

None.

Usage Notes

None.

Examples

Example 1: This example shows how to upload an image to a particular row in the table, and update other columns in that row at the same time.

<ord:uploadFormData formDataId="fd">
 <%
     java.util.Vector otherValuesVector = new java.util.Vector();
     otherValuesVector.add(fd.getParameter("desc")); 
     otherValuesVector.add(fd.getParameter("loc")); 
   %>
    <ord:storeMedia conn = "<% albumBean.getConnection() %>"
         table = "photos"  
         key = "<%= fd.getParameter( "desc" ) %>"
         mediaColumns = "photo" 
         mediaParameters = "photo" 
         otherColumns = "Description, Location"
         otherValues = "<%= otherValuesVector %>" />
</ord:uploadFormData> 

Example 2: This example shows how to upload image and audio data into a particular row in a table, at the same time.

<ord:uploadFormData formDataId="fd">
    <%
     java.util.Vector otherValuesVector = new java.util.Vector();
     otherValuesVector.add(fd.getParameter("desc")); 
     %>
    <ord:storeMedia conn = "<% albumBean.getConnection() %>"
         table = "photos"  
         key = "<%= fd.getParameter( "desc" ) %>"
         mediaColumns = "photo, music" 
         mediaParameters = "photo, music" 
         otherColumns = "Description" 
         otherValues = "<%= otherValuesVector %>" />
</ord:uploadFormData>

uploadFile

Format

<ord:uploadFile parameter = "string | <%= jspExpression %>"
[ mimeType = "string" ]
[ length = "string" ]
[ fullFileName = "string" ]
[ shortFileName = "string" ]
[ inputStream = "string" ] >
file-information-processing
</ord:uploadFile>

Description

Provides access to uploaded file information. This tag uses the object created by the uploadFormData tag implicitly, through the parameter attribute. This tag must be nested within the uploadFormData tag.

Parameters

parameter

The name of the parameter used to upload the file, as specified in the HTML form.

mimeType

The script variable name for the MIME type of the file.

length

The script variable name for the length of the file.

fullFileName

The script variable name for the file’s full file name.

shortFileName

The script variable name for the file’s short file name.

inputStream

The script variable name for the java.io.InputStream object for the uploaded file.

Exceptions

None.

Usage Notes

None.

Examples

This example shows how to use an uploadFile tag nested within an uploadFormData tag to enable access to various file attributes, including the MIME type, length, and name.

<ord:uploadFormData formDataId="fd">
  <%
    String desc = fd.getParameter( "desc" );
    String loc fd.getParameter( "loc" );
    <ord:uploadFile parameter = "photo"
                    mimeType = "photoType"
                    length = "photoLength"
                    fullFileName = "photoFullName"
                    shortFileName = "photoShortName">
                    inputStream = "photoIn">

   The mimeType of the file is <%=photoType%>
The length is <%=photoLength%> . . . </ord:uploadFile> %> </ord:uploadFormData>

where:


uploadFormData

Format

<ord:uploadFormData formDataId = "string"
[ releaseFormData = "true | false | <%= jspExpression %>" ]
[ maxMemory = "number | <%= jspExpression %>" ]
[ tempDir = "string | <%= jspExpression %>" ]
form-data-processing
</ord:uploadFormData>

Description

Parses the multipart/form-data HTTP request to provide access to text-based form parameters and the contents of uploaded files transmitted from a browser to a Web server.

Parameters

formDataId

The name of the script variable of type oracle.ord.im.OrdHttpUploadFormData from which the JSP page can obtain text-based form parameters and the contents of the uploaded files.

releaseFormData

Attribute used to retain uploaded media for processing after the end of the uploadFormData tag, such as in an included JSP page or a JSP page to which the request is forwarded. By default, the value of this attribute is true, which releases all uploaded media at the end of the tag. To retain the uploaded media, set the value of this attribute to false. Then, call the release( ) method in the OrdHttpUploadFormData object to release the resource when the uploaded media is no longer needed.

maxMemory

Attribute that specifies the maximum amount of memory that can be consumed by the uploaded media for one HTTP POST request before storing the media temporarily on disk. By default, all uploaded media is stored in memory until it is loaded into the database by the application and released at the end of the tag. In cases where users may want to upload large media files, such as large video clips, application developers can choose to store uploaded files temporarily on disk, before they are loaded into the database and released.

tempDir

Attribute that lets you override the default behavior. If this attribute is not specified, by default, uploaded media that is stored on disk temporarily is stored in one of the two locations identified by the following properties: javax.servlet.context.tempdir and java.io.tmpdir

where:

  • javax.servlet.context.tempdir, if present, takes precedence over java.io.tmpdir.


Note:

If execution of the JSP page is interrupted before the end of the uploadFormData tag, then any temporary files will be deleted either during garbage collection or when the user’s session ends, whichever occurs sooner.

Exceptions

None.

Usage Notes

This tag creates the form-data object, which is an object of type oracle.ord.im.OrdHttpUploadFormData. Access to upload form data is provided by the following methods:

Examples

This example shows how to use the Multimedia JSP tag uploadFormData to create a form-data object, which the JavaBean called albumBean uses to access the text-based form parameters and the uploaded file content.

<ord:uploadFormData formDataId="fd">
  <%
    albumBean.setDescription( fd.getParameter( "desc" ) );
    albumBean.setLocation( fd.getParameter( "loc" ) );
    albumBean.insertNewEntry();
    albumBean.fetchRow();
    albumBean.loadPhoto( fd.getFileParameter( "photo" ) );
    albumBean.updateRow();
    albumBean.commit();
  %>
</ord:uploadFormData>