0

We have a web application developed in JSPs. We have to perform audit trail for every changed field in the screen. The audit table should contain the following columns: unique_id, old value, new value, name of the screen field, last updated date, last updated user. Kindly suggest some design patterns and best practices for such auditing.

Note: we are currently trying using the filter pattern to intercept the requests from JSPs and audit in the tables. We do not need the DB trigger based auditing as the screen field name is different from DB column name. We have to audit based on the screen field names.

Thanks in advance, Rajanikanth

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555

1 Answers1

0

This is a common question. Use an Aspect, which keeps the audit code completely separate from core business code. In your case, in the Aspect you would grab the DB version of the object and then diff its values to the values in the submitted object, logging the info in an audit table.

If you are using Spring: Security access audit.

Community
  • 1
  • 1
atrain
  • 9,139
  • 1
  • 36
  • 40
  • Hi Aaron, Thanks for the reply. Unfortunately, our application does not use Springs framework. It is a sort of a legacy code with the JSP - Command Pattern - Helper kind of workflow. Can you suggest some design pattern which would fit in this scenario. – Rajanikanth Jul 30 '11 at 12:17
  • You could still use AspectJ without Spring. Here's a tutorial: http://www.andrewewhite.net/wordpress/2010/03/17/aspectj-annotation-tutorial/. The important things about Aspects is that they allow you to encapsulate code which does something and apply it to different situations. In your case, you can create an auditing aspect and configure it to fire when your Command object fires, or in some other similar case. – atrain Jul 31 '11 at 01:40