LEDGE-252: facilities for validating request origin for CORS
LEDGE-251: set content type before fetching printWriter (avoids NPE),
removed duplicated variable
LEDGE-252: added CORS support
LEDGE-252: switch from JSONP to POST with CORS