#CaptureResponse.py #A Response Filter to Capture and Modify the Response without Overriding #This will lead to illegal state exception from javax import servlet from javax.servlet import http from java.lang import * from java.io import * import string , sys class CaptureResponse(servlet.Filter): def doFilter(self, req, res,chain): #Capture the Stream which writes response to the client chain.doFilter(req, res) toclient = res.getWriter() def init(self, config): print "Capture Response filter Initialized" def destroy(self): print "Capture Response filter Destroyed" sys.exit(0)