java.util.Enumeration Descriptor Schema Actions ESQL file-upload-blob personnel select media.id from media image/ no images yet

Upload Media

What's happening? This example interacts with a simple database schema, set up by default in the sample "personnel" hsql database installed with the database block. There is one table "media" with two fields: a primary key, and a binary field "image". When a file upload is received from the simple form on this page, the modular db action auto increments the primary key, and loads the binary file contents into the column (declared as type="binary" in database.xml). That's it.

Additionally, when this page is loaded, esql queries the media table and places an image tag for each row, using "primarykeyvalue".jpg for the src. The sitemap is configured to serve *.jpg using the database reader (declared in the root database samples sitemap) which simply retrieves the binary data from the database and streams it to the browser.

The default installation of Apache Cocoon does not allow uploads. This feature needs to be enabled in web.xml

File (must be an image)

Request Attributes

{ Enumeration e=request.getAttributeNames(); while ( e.hasMoreElements() ) { String attribute = (String) e.nextElement(); Object value = request.getAttribute(attribute); } }
attribute ="value"


Request Parameters

{ Enumeration e=request.getParameterNames(); while ( e.hasMoreElements() ) { String attribute = (String) e.nextElement(); Object[] value = request.getParameterValues(attribute); for (int i=0; i < value.length; i++) { } } }
attribute[i] ="value[i]"