Variable var = myModule .resolveVariable(ResponseModule.RESPONSE_VAR);
    public static void addLastModifiedHeader(Sequence result,			XQueryContext context) {		try {			DocumentSet documentSet = result.getDocumentSet();			long mostRecentDocumentTime = 0;			for (int i = 0; i < documentSet.getLength(); i++) {				DocumentImpl doc = (DocumentImpl) documentSet.item(i);				if (doc != null) {					mostRecentDocumentTime = Math.max(doc.getMetadata().getLastModified(),							mostRecentDocumentTime);//					LOG.debug("getFileName: " + doc.getFileName() + ", "//							+ doc.getLastModified());				}			}			LOG.debug("mostRecentDocumentTime: " + mostRecentDocumentTime);			if (mostRecentDocumentTime > 0) {				ResponseModule myModule = (ResponseModule) context						.getModule(ResponseModule.NAMESPACE_URI);								// response servlet object is read from global variable $response				Variable var = myModule						.resolveVariable(ResponseModule.RESPONSE_VAR);				if (var != null) {					JavaObjectValue value = (JavaObjectValue) var.getValue()							.itemAt(0);					if (value != null							&& value.getObject() instanceof ResponseWrapper) {						// have to take in account that if the header has allready been explicitely set 						// by the XQuery script, we should not modify it .						ResponseWrapper responseWrapper = ((ResponseWrapper) value.getObject());						if ( responseWrapper.getDateHeader("Last-Modified") == 0 )							responseWrapper.setDateHeader(								"Last-Modified", mostRecentDocumentTime);					}				}			}		} catch (Exception e) {			LOG.debug(e);		}	}