public void marshallException(HttpServletRequest request, HttpServletResponse response, ScriptConduit conduit, Exception ex, boolean sendPrefix) throws IOException { String batchId = null; String instanceId = "0"; String documentDomain = null; Batch batch = (Batch) request.getAttribute(ATTRIBUTE_BATCH); if (batch != null) { batchId = batch.getBatchId(); instanceId = batch.getInstanceId(); documentDomain = batch.getDocumentDomain(); } PrintWriter out = response.getWriter(); if (conduit == null) { conduit = createScriptConduit(out, instanceId, batchId, documentDomain); } response.setContentType(conduit.getOutboundMimeType()); if (sendPrefix) { conduit.beginStreamAndChunk(); } String script = EnginePrivate.getRemoteHandleBatchExceptionScript(batchId, ex); out.println(script); conduit.endStreamAndChunk(); }
private void beginStreamAndChunk() throws Exception { response.setContentType(conduit.getOutboundMimeType()); // If there is a runnable for beginning of response then run it RealScriptSession.Script script = scriptSession.getScript(nextScriptIndex); boolean beginningRunnable = false; if (script != null && script.getScript() instanceof Runnable) { try { ((Runnable) script.getScript()).run(); } catch(Exception ex) { log.error("Exception when executing Script Runnable.", ex); } beginningRunnable = true; } // Send stream prefix conduit.beginStreamAndChunk(); // Send confirmation for the runnable to client after stream prefix if (beginningRunnable) { conduit.sendScript(EnginePrivate.getRemoteHandleReverseAjaxScript(script.getIndex(), "")); nextScriptIndex = script.getIndex() + 1; } }
response.setContentType(conduit.getOutboundMimeType()); if (passiveReverseAjax)