You should be able to get this from the Context.
IMxRuntimeResponse mxResponse = getContext().getRuntimeResponse().get();
https://apidocs.rnd.mendix.com/9/runtime/com/mendix/m2ee/api/IMxRuntimeResponse.html
Once you have the IMxRuntimeResponse you can call the getHttpServletResponse() method.
https://apidocs.rnd.mendix.com/9/runtime/com/mendix/m2ee/api/IMxRuntimeResponse.html#getHttpServletResponse()