Request filters are invoked when a request is received from a database client.
Response filters are invoked when a response is received from the database server.
Duplex filters are invoked in both cases.
Filters are given the opportunity to look at the packet and do whatever they want with it: let it through, modify it, or reject it. Unless it's rejected, the packet is then forwarded to its destination.
Note that the term "packet" is used loosely here -- any many cases the filter will not actually interact with a single packet, because (for instance) result sets are comprised of several actual packets. This is only relevant in advanced use cases.
All filters define the following variables, which can be accessed from your JavaScript code:
log : A Logger object to output messages to the logging system
context : a container object described in the DB2 Contexts page
JavaScript request filter : invoked for any request from clients
Query filter: invoked for incoming SQL statements
Set filter: invoked for SET statements
Prepared statement filter: invoked for executions of prepared statements
Request logging filter: logs request packets to standard log or to a log file
JavaScript response filter: invoked for any response from the database server
Result set filter: invoked for every row in a result set, whether from a SQL query or a stored procedure call
Response logging filter: logs response packets to standard log or to a log file
JavaScript duplex filter: can be invoked for any requests or responses.
Connection filters are also available if you need to execute logic when a connection to the database is opened or closed.