All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class nl.nmg.servlet.UploadedFileUtils

java.lang.Object
   |
   +----nl.nmg.servlet.UploadedFileUtils

public class UploadedFileUtils
extends Object
The UploadedFileUtils class contains a number of utility methods to handle the moving of uploaded files to and from a database.

Sample code to demonstrate this should be provided.


Method Index

 o displayFile(Connection, String, String, String, HttpServletResponse)
Writes the contents of the specified file to the output stream of the HttpServletResponse object.
 o editFile(ResultSet, String, HTMLWriter)
Displays a file input form element, and optionally a file-delete checkbox.
 o updateFile(ExtendedRequest, Connection, String, String, String)
Copies the contents and meta-data of the specified file into the database.

Methods

 o editFile
 public static void editFile(ResultSet rs,
                             String sqlColumn,
                             HTMLWriter out) throws SQLException
Displays a file input form element, and optionally a file-delete checkbox.

Parameters:
rs - a result set set at the location of the row that contains the file.
sqlColumn - the column in the table that contains the file data. If the column name is "image", the column "image_ct" should contain the content-type and the column "image_fn" should contain the client-side filename.
out - the writer where the form element should be printed.
Throws: SQLException
when a database related error occurs
 o updateFile
 public static void updateFile(ExtendedRequest extReq,
                               Connection conn,
                               String sqlTable,
                               String sqlColumn,
                               String sqlCondition) throws SQLException, IOException
Copies the contents and meta-data of the specified file into the database. If the file-delete checkbox was checked, the data is set to NULL instead.

Parameters:
extReq - the request object that contains the file
conn - the database connection
sqlTable - the table in the database that contains the file
sqlColumn - the column in the table that contains the file data. If the column name is "image", the column "image_ct" should contain the content-type and the column "image_fn" should contain the client-side filename.
sqlCondition - a WHERE clause that selects the appropiate row
Throws: SQLException
when a database related error occurs
 o displayFile
 public static void displayFile(Connection conn,
                                String sqlTable,
                                String sqlColumn,
                                String sqlCondition,
                                HttpServletResponse res) throws SQLException, IOException
Writes the contents of the specified file to the output stream of the HttpServletResponse object. The content-type is also set correctly.

Parameters:
conn - the database connection
sqlTable - the table in the database that contains the file
sqlColumn - the column in the table that contains the file data. If the column name is "image", the column "image_ct" should contain the content-type and the column "image_fn" should contain the client-side filename.
sqlCondition - a WHERE clause that selects the appropiate row
res - the target of the file
Throws: SQLException
when a database related error occurs
Throws: IOException
when an I/O error occurs

All Packages  Class Hierarchy  This Package  Previous  Next  Index