/** * Reset response attributes to support printing out a new page (rather than one that potentially errored out). * This includes clearing clientlib inclusion state, and resetting the response. * <p> * If the response is committed, and it hasnt been closed by code, check the response AND jsp buffer sizes and * ensure they are large enough to NOT force a buffer flush. * * @param request * @param response * @param statusCode */ public void resetRequestAndResponse(SlingHttpServletRequest request, SlingHttpServletResponse response, int statusCode) { // Clear client libraries // Replace with proper API call is HtmlLibraryManager provides one in the future; // Currently this is our only option. request.setAttribute("com.day.cq.widget.HtmlLibraryManager.included", new HashSet<String>()); // Fixes AEM 6.2 issue (https://github.com/Adobe-Consulting-Services/acs-aem-commons/issues/790) request.setAttribute("com.adobe.granite.ui.clientlibs.HtmlLibraryManager.included", new HashSet<String>()); // Clear the response response.reset(); response.setContentType("text/html"); response.setStatus(statusCode); }
/** * Reset response attributes to support printing out a new page (rather than one that potentially errored out). * This includes clearing clientlib inclusion state, and resetting the response. * <p> * If the response is committed, and it hasnt been closed by code, check the response AND jsp buffer sizes and * ensure they are large enough to NOT force a buffer flush. * * @param request * @param response * @param statusCode */ @Override public void resetRequestAndResponse(SlingHttpServletRequest request, SlingHttpServletResponse response, int statusCode) { // Clear client libraries. Would be better if there was a proper API call for this, but there isn't at present. request.setAttribute("com.day.cq.widget.HtmlLibraryManager.included", new HashSet<String>()); // Fixes AEM 6.2 issue (https://github.com/Adobe-Consulting-Services/acs-aem-commons/issues/790) request.setAttribute("com.adobe.granite.ui.clientlibs.HtmlLibraryManager.included", new HashSet<String>()); //Reset the component context attribute to remove inclusion of response from top level components request.removeAttribute("com.day.cq.wcm.componentcontext"); // Clear the response response.reset(); response.setContentType("text/html"); response.setStatus(statusCode); }
slingResponse.reset(); slingResponse.setContentType("text/html"); slingResponse.setStatus(errorCode);
response.reset(); throw new ServletException("Unable to produce JSON", e);
response.reset(); response.setStatus(status); response.setHeader("Location", isUrl(targetPath) ? targetPath : response.encodeRedirectURL(targetPath));