List of usage examples for javax.servlet ServletResponse setContentType
public void setContentType(String type);
From source file:org.wso2.adminui.AdminUIServletFilter.java
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { try {// w w w .ja v a 2s .com HttpServletRequest httpServletRequest = (HttpServletRequest) request; if (contextRoot == null) { //Context root could be "" or some othervalue this.contextRoot = httpServletRequest.getContextPath(); } String requestURI = httpServletRequest.getRequestURI(); int indexOfDot = requestURI.lastIndexOf("."); boolean isFile = false; if (indexOfDot != -1) { isFile = requestURI.substring(indexOfDot).matches("\\.(.)*"); } if (!isFile && requestURI.lastIndexOf("/") != requestURI.length() - 1) { requestURI += "/"; } Map generatedPages = (Map) servletContext.getAttribute(AdminUIConstants.GENERATED_PAGES); if (requestURI.equals(contextRoot) || requestURI.equals(contextRoot + "/")) { response.setContentType("text/html"); boolean enableConsole = ((Boolean) servletContext.getAttribute(AdminUIConstants.ENABLE_CONSOLE)) .booleanValue(); if (!enableConsole) { ServletOutputStream out = response.getOutputStream(); out.write(("<b>Management Console has been disabled.</b> " + "Enable it in the server.xml and try again.").getBytes()); ((HttpServletResponse) response).setStatus(HttpServletResponse.SC_FORBIDDEN); out.flush(); out.close(); return; } String fileContents = (String) generatedPages.get("index.html"); if (fileContents != null) { ServletOutputStream op = response.getOutputStream(); response.setContentLength(fileContents.getBytes().length); op.write(fileContents.getBytes()); return; } } else { String urlKey; if (contextRoot.equals("/")) { urlKey = requestURI.substring(contextRoot.length(), requestURI.length()); } else { urlKey = requestURI.substring(1 + contextRoot.length(), requestURI.length()); } if (generatedPages != null) { String fileContents = (String) generatedPages.get(urlKey); if (fileContents != null) { ServletOutputStream op = response.getOutputStream(); response.setContentType("text/html"); response.setContentLength(fileContents.getBytes().length); op.write(fileContents.getBytes()); return; } } /* || has been used to support any client who wants to access the "global_params.js" regardless of where they want to access. */ if (urlKey.equals(GLOBAL_PARAMS_JS) || urlKey.indexOf(GLOBAL_PARAMS_JS) > -1) { initGlobalParams((HttpServletResponse) response); return; } } } catch (Exception e) { String msg = "Exception occurred while processing Request"; log.error(msg, e); throw new ServletException(msg, e); } filterChain.doFilter(request, response); }
From source file:org.codeconsole.web.analytics.AnalyticsFilter.java
/** * @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain) *///from w w w.jav a2 s .c om public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpRequest = (HttpServletRequest) request; HttpStatusExposingServletResponse httpResponse = new HttpStatusExposingServletResponse( (HttpServletResponse) response); AnalyticsSession analyticsSession = (AnalyticsSession) httpRequest.getSession() .getAttribute(sessionAttributeName); if (analyticsSession == null) { analyticsSession = new AnalyticsSession(maxHistorySize, httpRequest.getHeader("referer"), getIp(httpRequest)); httpRequest.getSession().setAttribute(sessionAttributeName, analyticsSession); } String compareUrl = getComparisonUrl((HttpServletRequest) request); if (compareUrl.endsWith(analyticsUrl)) { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<html><head><title>Analytics Report</title></head><body>"); if (ServletRequestUtils.getBooleanParameter(request, "send", false)) { if (analyticsGateway != null) { analyticsGateway.sendAnalytics(analyticsSession); } else { out.println( "<div>Warning: Can't send report. No Spring application context specified/configured.</div>"); } out.println("<div>Message: Report Sent!</div>"); } if (ServletRequestUtils.getBooleanParameter(request, "clear", false)) { analyticsSession.clear(); httpRequest.getSession().setAttribute(sessionAttributeName, analyticsSession); out.println("<div>Message: History Cleared!</div>"); } out.print( "<div><a href=\"?\">Refresh</a> <a href=\"?clear=true\">Clear</a> <a href=\"?send=true\">Send</a> <a href=\"?send=true&clear=true\">Send and Clear</a></div>"); out.print(analyticsSession.toHtmlString()); out.println("</body></html>"); out.close(); } else { String sourceRevision = sourceRevisionResolver == null ? null : sourceRevisionResolver.getRevision(httpRequest); Map<String, String[]> filteredParamMap = request.getParameterMap(); if (!excludedUrlPatterns.isEmpty()) { filteredParamMap = new HashMap<String, String[]>(); for (Iterator<Map.Entry<String, String[]>> it = request.getParameterMap().entrySet().iterator(); it .hasNext();) { Entry<String, String[]> next = it.next(); for (Pattern exclude : excludedUrlPatterns) { if (exclude.matcher(compareUrl).matches()) { filteredParamMap.put(next.getKey(), new String[] { "**FILTERED**" }); } else { filteredParamMap.put(next.getKey(), next.getValue()); } } } } @SuppressWarnings("unchecked") AnalyticsHttpRequest rq = new AnalyticsHttpRequest(httpRequest.getMethod(), httpRequest.getRequestURL().toString(), httpRequest.getQueryString(), filteredParamMap, sourceRevision); try { chain.doFilter(request, httpResponse); } catch (IOException e) { rq.setException(e); throw e; } catch (ServletException e) { rq.setException(e); throw e; } catch (RuntimeException e) { rq.setException(e); throw e; } finally { rq.setCompletionTime(System.currentTimeMillis()); rq.setStatus(httpResponse.getStatus()); boolean ignore = false; if (rq.getStatus() == 200 || rq.getStatus() == 304) { for (Pattern exclude : excludedUrlPatterns) { if (exclude.matcher(compareUrl).matches()) { ignore = true; break; } } } if (!ignore) { analyticsSession.appendHistory(rq); } Serializable userDetails = userDetailsResolver == null ? null : userDetailsResolver.getUserDetails(httpRequest); if (userDetails != null && (analyticsSession.getUserDetails() == null || !analyticsSession.getUserDetails().equals(userDetails))) { analyticsSession.setUserDetails(userDetails); } // in case of clustered sessions, always update the session object to propagate the update. if (!httpResponse.isCommitted()) { httpRequest.getSession().setAttribute(sessionAttributeName, analyticsSession); } if (rq.getWrappedException() != null && analyticsGateway != null) { analyticsGateway.sendAnalytics(analyticsSession); } } } }
From source file:com.mobileman.filter.SecurityCheckFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { HttpServletRequest rq1 = (HttpServletRequest) request; String requestURI = rq1.getRequestURI().toLowerCase(); DataHolder holder = new DataHolder(rq1); boolean error = false; if (requestURI.contains("/patient/")) { //check patient loaded if (!holder.isPatient()) { error = true;//from w w w . j a v a 2 s. c o m } } else if (requestURI.contains("/arzt/")) { //check doctor loaded if (!holder.isDoctor()) { error = true; } } else if (requestURI.contains("/admin/") && !requestURI.contains("/admin/anmeldung")) { //check admin loaded if (!holder.isAdmin()) { error = true; } } /////////////// if (requestURI.contains("/public")) { //redirect to /behandlung StringBuffer sb = rq1.getRequestURL(); String newUrl = StringUtils.replace(sb.toString(), "/public", "/behandlung"); java.io.PrintWriter out = response.getWriter(); response.setContentType("text/html"); out.println("<html>"); out.println("<head>"); out.println("<meta http-equiv=\"refresh\" content=\"0;url="); out.print(newUrl); out.println("\" />"); out.println("</head>"); out.println("<body>"); out.println("</body>"); out.println("</html>"); return; } if (error) { //redirect request.getRequestDispatcher("/").forward(request, response); return; } filterChain.doFilter(request, response); }
From source file:org.apache.myfaces.custom.ajax.api.AjaxDecodePhaseListener.java
private void encodeAjax(UIComponent component, FacesContext context) { ServletResponse response = (ServletResponse) context.getExternalContext().getResponse(); ServletRequest request = (ServletRequest) context.getExternalContext().getRequest(); UIViewRoot viewRoot = context.getViewRoot(); Map requestMap = context.getExternalContext().getRequestParameterMap(); String charset = (String) requestMap.get("charset"); /* Handle character encoding as of section 2.5.2.2 of JSF 1.1: * At the beginning of the render-response phase, the ViewHandler must ensure * that the response Locale is set to that of the UIViewRoot, for exampe by * calling ServletResponse.setLocale() when running in the servlet environment. * Setting the response Locale may affect the response character encoding. */* w ww. j av a 2s.c o m*/ * Since there is no 'Render Response' phase for AJAX requests, we have to handle * this manually. */ response.setLocale(viewRoot.getLocale()); if (component instanceof DeprecatedAjaxComponent) { try { String contentType = getContentType("text/xml", charset); response.setContentType(contentType); StringBuffer buff = new StringBuffer(); buff.append("<?xml version=\"1.0\"?>\n"); buff.append("<response>\n"); PrintWriter out = response.getWriter(); out.print(buff); // imario@apache.org: setup response writer, otherwise the component will fail with an NPE. I dont know why this worked before. context.setResponseWriter( new HtmlResponseWriterImpl(out, contentType, request.getCharacterEncoding())); if (component instanceof HtmlCommandButtonAjax) { buff = new StringBuffer(); buff.append("<triggerComponent id=\""); buff.append(component.getClientId(context)); buff.append("\" />\n"); out.print(buff); // special treatment for this one, it will try to update the entire form // 1. get surrounding form //String elname = (String) requestMap.get("elname"); FormInfo fi = RendererUtils.findNestingForm(component, context); UIComponent form = fi.getForm(); //System.out.println("FOUND FORM: " + form); if (form != null) { // special case, add responses from all components in form encodeChildren(form, context, requestMap); } } else if (component instanceof AjaxComponent) { // let component render xml response // NOTE: probably don't need an encodeAjax in each component, but leaving it in until that's for sure ((AjaxComponent) component).encodeAjax(context); } else { // just get latest value AjaxRendererUtils.encodeAjax(context, component); } // end response out.print("</response>"); out.flush(); } catch (IOException e) { log.error("Exception while rendering ajax-response", e); } } else if (component instanceof AjaxComponent) { try { if (context.getResponseWriter() == null) { String contentType = getContentType("text/html", charset); response.setContentType(contentType); PrintWriter writer = response.getWriter(); context.setResponseWriter( new HtmlResponseWriterImpl(writer, contentType, response.getCharacterEncoding())); } ((AjaxComponent) component).encodeAjax(context); } catch (IOException e) { log.error("Exception while rendering ajax-response", e); } } }
From source file:org.xchain.namespaces.servlet.ResultCommand.java
public boolean execute(JXPathContext context) throws Exception { ServletResponse response = getResult(context); // set the result in the pipeline config's composite stage Result result = new StreamResult(response.getOutputStream()); PipelineCommand.getPipelineConfig().getCompositeStage().setResult(result); // set the content type for the response ContentType contentType;/*from w w w.jav a 2s. c o m*/ String requestedMediaType = hasMediaType() ? getMediaType(context) : PipelineCommand.getPipelineConfig().getCompositeStage().getMediaType(); String requestedEncoding = PipelineCommand.getPipelineConfig().getCompositeStage().getEncoding(); String charset = ContentType.DEFAULT_CHARSET; if (requestedEncoding != null) { charset = ContentType.ATTR_CHARSET + "=" + requestedEncoding; } if (requestedMediaType != null) { contentType = new ContentType(requestedMediaType + ";" + charset); } else { contentType = ContentType.TEXT_HTML; } // If the browser does not accept XHTML and we are requesting XHTML, default to HTML String acceptHeader = ((HttpServletRequest) getRequest(context)).getHeader("Accept"); if (contentType.mediaTypeMatch(ContentType.TEXT_XHTML) && !ContentType.acceptsContentType(acceptHeader, ContentType.TEXT_XHTML)) { contentType = ContentType.TEXT_HTML; } response.setContentType(contentType.toString()); if (getDisableCaching(context)) { disableCaching((HttpServletResponse) response); } return false; }
From source file:org.opencms.search.solr.CmsSolrIndex.java
/** * Writes the Solr response.<p>//from w ww . jav a2s . c o m * * @param response the servlet response * @param queryRequest the Solr request * @param queryResponse the Solr response to write * * @throws IOException if sth. goes wrong * @throws UnsupportedEncodingException if sth. goes wrong */ private void writeResp(ServletResponse response, SolrQueryRequest queryRequest, SolrQueryResponse queryResponse) throws IOException, UnsupportedEncodingException { if (m_solr instanceof EmbeddedSolrServer) { SolrCore core = ((EmbeddedSolrServer) m_solr).getCoreContainer().getCore(getCoreName()); Writer out = null; try { QueryResponseWriter responseWriter = core.getQueryResponseWriter(queryRequest); final String ct = responseWriter.getContentType(queryRequest, queryResponse); if (null != ct) { response.setContentType(ct); } if (responseWriter instanceof BinaryQueryResponseWriter) { BinaryQueryResponseWriter binWriter = (BinaryQueryResponseWriter) responseWriter; binWriter.write(response.getOutputStream(), queryRequest, queryResponse); } else { String charset = ContentStreamBase.getCharsetFromContentType(ct); out = ((charset == null) || charset.equalsIgnoreCase(UTF8.toString())) ? new OutputStreamWriter(response.getOutputStream(), UTF8) : new OutputStreamWriter(response.getOutputStream(), charset); out = new FastWriter(out); responseWriter.write(out, queryRequest, queryResponse); out.flush(); } } finally { core.close(); if (out != null) { out.close(); } } } else { throw new UnsupportedOperationException(); } }
From source file:org.onehippo.forge.hst.pdf.renderer.servlet.HtmlPDFRenderingFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (!(response instanceof HttpServletResponse)) { chain.doFilter(request, response); return;//from w w w .j a va 2 s . c om } if (response.isCommitted()) { log.warn("The servlet response is already committed for the request: '{}'.", ((HttpServletRequest) request).getRequestURI()); chain.doFilter(request, response); return; } ContentCapturingHttpServletResponse capturingResponse = null; InputStream htmlInputStream = null; Reader htmlReader = null; OutputStream pdfOutputStream = null; try { capturingResponse = new ContentCapturingHttpServletResponse((HttpServletResponse) response); chain.doFilter(request, capturingResponse); if (capturingResponse.isWrittenToPrintWriter()) { htmlReader = new CharArrayReader(capturingResponse.toCharArray()); } else { htmlInputStream = new ByteArrayInputStream(capturingResponse.toByteArray()); String characterEncoding = StringUtils.defaultIfBlank(capturingResponse.getCharacterEncoding(), "UTF-8"); htmlReader = new InputStreamReader(htmlInputStream, characterEncoding); } capturingResponse.close(); capturingResponse = null; response.setContentType("application/pdf"); StringBuilder headerValue = new StringBuilder("attachment"); headerValue.append("; filename=\"").append(getDocumentFilename((HttpServletRequest) request)) .append("\""); ((HttpServletResponse) response).addHeader("Content-Disposition", headerValue.toString()); pdfOutputStream = response.getOutputStream(); pdfRenderer.renderHtmlToPDF(htmlReader, true, pdfOutputStream, getDocumentURL((HttpServletRequest) request), getExternalLinkBaseURL((HttpServletRequest) request)); } catch (Exception e) { } finally { if (capturingResponse != null) { capturingResponse.close(); } IOUtils.closeQuietly(pdfOutputStream); IOUtils.closeQuietly(htmlReader); IOUtils.closeQuietly(htmlInputStream); } }
From source file:cc.kune.core.server.searcheable.SearchEngineServletFilter.java
@Override public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException, DefaultException { if (filterConfig == null) { return;//from w ww . jav a 2s. c o m } if (request instanceof HttpServletRequest) { final HttpServletRequest httpReq = (HttpServletRequest) request; final StringBuffer url = httpReq.getRequestURL(); final String queryString = httpReq.getQueryString(); if ((queryString != null) && (queryString.contains(SiteParameters.ESCAPED_FRAGMENT_PARAMETER))) { if (!enabled) { final HttpServletResponse httpRes = (HttpServletResponse) response; httpRes.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "Search Engine service disabled temporally"); return; } // rewrite the URL back to the original #! version // remember to unescape any %XX characters final String urlWithEscapedFragment = request .getParameter(SiteParameters.ESCAPED_FRAGMENT_PARAMETER); final String newUrl = url.append("?").append(queryString).toString() .replaceFirst(SiteParameters.ESCAPED_FRAGMENT_PARAMETER, SiteParameters.NO_UA_CHECK) .replaceFirst("/ws", "") + "#" + urlWithEscapedFragment; LOG.info("New url with hash: " + newUrl); final String page = "In development"; // return the snapshot response.setCharacterEncoding("UTF-8"); response.setContentType("text/html; charset=UTF-8"); response.getOutputStream().write(page.getBytes()); } else { try { // not an _escaped_fragment_ URL, so move up the chain of // servlet (filters) chain.doFilter(request, response); } catch (final ServletException e) { LOG.error("Servlet exception caught: " + e); } } } }
From source file:fr.openwide.talendalfresco.rest.server.CommandAuthenticationFilter.java
/** * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain) *//*from w ww . j a va 2 s . co m*/ public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpReq = (HttpServletRequest) req; HttpServletResponse httpRes = (HttpServletResponse) res; // checking whether this request is has enough info for ticket auth by CommandServlet boolean ticketAuth = false; String ticket = req.getParameter(ARG_TICKET); if (ticket == null || ticket.length() == 0) { // no ticket sent, maybe there's still a User in session with one ? HttpSession session = httpReq.getSession(false); if (session != null) { ticketAuth = (session.getAttribute(AuthenticationHelper.AUTHENTICATION_USER) != null); } } else { ticketAuth = true; } if (ticketAuth) { // this request is ready for ticket auth by the CommandServlet // so let's forward it to the CommandServlet, which will auth its ticket // and then do whatever Command it wants try { chain.doFilter(req, res); } catch (Throwable t) { String msg = "Unknown internal error"; logger.error(msg, t); // attempting to output response RestServerHelper.outputErrorResponse(httpRes, msg, t); } return; } // else not logged in yet // now attempting login : try { RestCommandProcessor processor = this.login(httpReq, httpRes); // output processor state with Command result res.setContentType("text/xml"); PrintWriter out = httpRes.getWriter(); processor.outputStatus(out); out.close(); } catch (Throwable t) { String msg = "Error during command auth filter processing: " + t.getMessage(); logger.error(msg, t); // attempting to output response RestServerHelper.outputErrorResponse(httpRes, msg, t); } }
From source file:org.xmlactions.web.conceal.HttpPager.java
public void processPage(ServletRequest request, ServletResponse response, String page) throws ServletException, IOException { IExecContext execContext = null;// ww w .j ava 2s . c om if (response instanceof HttpServletResponse && request instanceof HttpServletRequest) { try { HttpServletRequest httpServletRequest = (HttpServletRequest) request; HttpServletResponse httpServletResponse = (HttpServletResponse) response; execContext = setupExecContext(httpServletRequest, httpServletResponse); String pageName = httpServletRequest.getServletPath(); if (pageName.indexOf("axelconfig") > 0) { PrintWriter out = response.getWriter(); out.print(buildInfo(httpServletRequest, httpServletResponse)); out.close(); return; } if (!pageName.endsWith(".ajax")) { String alternatePage = processPrePages(execContext, httpServletRequest, httpServletResponse); if ("stop".equals(execContext.getString("pre.page.stop"))) { execContext.put("pre.page.stop", ""); response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); out.print(alternatePage); out.close(); } } log.debug("contextPath:" + httpServletRequest.getContextPath()); log.debug("URI:" + httpServletRequest.getRequestURI()); log.debug("root:" + realPath + " page:" + pageName + " wrapperPage:" + wrapperPage); log.debug(HttpSessionInfo.sysInfo(httpServletRequest)); Action action; if (pageName.endsWith(".ajax")) { page = processAjaxCall(httpServletRequest, httpServletResponse, pageName.substring(1, pageName.length() - ".ajax".length()), execContext); page = StrSubstitutor.replace(page, execContext); } else if (pageName.endsWith(".bin") || pageName.endsWith(".pdfbin")) { String pn = null; if (pageName.endsWith(".pdfbin")) { pn = pageName.substring(1, pageName.length() - ".pdfbin".length()); } else { pn = pageName.substring(1, pageName.length() - ".bin".length()); } page = processAjaxCall(httpServletRequest, httpServletResponse, pn, execContext); if (page.startsWith("EX:")) { PrintWriter out = response.getWriter(); out.print(page); out.close(); } else { byte[] image = (byte[]) execContext.get("image"); if (pageName.endsWith(".pdfbin")) { String outputPdfFileName = execContext.getString("outputFileName"); String ex = serviceJasperPdfRequest(httpServletResponse, image, outputPdfFileName); if (ex != null) { PrintWriter out = response.getWriter(); out.print(page); out.close(); } return; } else { String responseType = execContext.getString("response_type"); if (StringUtils.isEmpty(responseType)) { responseType = "image/png"; } response.setContentType(responseType); processPostPages(execContext, httpServletRequest, httpServletResponse); InputStream in = new ByteArrayInputStream(image); OutputStream out = response.getOutputStream(); // Copy the contents of the file to the output // stream byte[] buf = new byte[1024]; int count = 0; while ((count = in.read(buf)) >= 0) { out.write(buf, 0, count); } in.close(); out.close(); } return; } } else { if (pageName.startsWith("/:")) { String wrapperPageName = null; int secondColon = pageName.indexOf(':', 2); if (secondColon >= 0) { wrapperPageName = pageName.substring(2, secondColon); execContext.put("inner_page", "/" + pageName.substring(secondColon + 1)); } else { if (StringUtils.isEmpty(wrapperPage)) { throw new ServletException("No wrapper page set, why use :"); } wrapperPageName = wrapperPage; execContext.put("inner_page", "/" + pageName.substring(2)); } // insert the requested page into the wrapper page action = new Action(realPath, wrapperPageName, nameSpace); } else { if (StringUtils.isNotEmpty(wrapperPage)) { // we have a base wrapper page defined execContext.put("inner_page", "/" + pageName); action = new Action(realPath, wrapperPage, nameSpace); } else { if (pageName.indexOf("show_axel_config") >= 0) { page = AxelConfig.getAxelConfig(execContext); log.info(page); page = "Config Copied to Log"; action = null; } else { // if we don't have a wrapper page we show the requested page action = new Action(realPath, pageName, nameSpace); } } } if (action != null) { if (StringUtils.isNotEmpty(page)) { page = action.processPage(execContext, page); } else { page = action.processPage(execContext); } } } log.debug("URI:" + httpServletRequest.getRequestURI()); // log.debug("page:" + page); Object object = execContext.get(ActionConst.NO_STR_SUBST); // log.debug(ActionConst.NO_STR_SUBST + ":[" + object + "]"); execContext.put(ActionConst.NO_STR_SUBST, null); if (pageName.toLowerCase().endsWith("soap")) { response.setContentType(IExecContext.CONTENT_TYPE_XML); } else if (pageName.toLowerCase().endsWith("json")) { response.setContentType(IExecContext.CONTENT_TYPE_JSON); } else { response.setContentType(IExecContext.CONTENT_TYPE_HTML); } processPostPages(execContext, httpServletRequest, httpServletResponse); // = = = // check if there is a contentType value stored in the execContext. This could have been set by one of the actions such as an action that wants to return a JSON data. // = = = String contentType = execContext.getString(IExecContext.CONTENT_TYPE_KEY); if (StringUtils.isNotBlank(contentType)) { response.setContentType(contentType); // if (contentType.equals(IExecContext.CONTENT_TYPE_JSON) || contentType.equals(IExecContext.CONTENT_TYPE_XML)) { // if (response instanceof HttpServletResponse) { // ((HttpServletResponse)response).setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1 // ((HttpServletResponse)response).setHeader("Pragma", "no-cache"); // HTTP 1.0 // ((HttpServletResponse)response).setDateHeader("Expires", 0); // Proxies. // } // } } execContext.remove("content_type"); PrintWriter out = response.getWriter(); out.print(page); out.close(); } catch (Throwable t) { // TODO review this, use a better way for reporting the error. log.info(t.getMessage(), t); throw new ServletException(t); } finally { if (execContext != null) { execContext.saveToPersistence(); RequestExecContext.remove(); } } } else { String msg = "Not processing page. Must be HttpServletRequest not [" + request.getClass().getName() + "] and HttpServletResponse not [" + response.getClass().getName() + "]"; log.info(msg); throw new ServletException(msg); } }