Source:
<code>protected final void service(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException { VelocityRequestWrapper request = new VelocityRequestWrapper(req); final String uri = CMSUrlUtil.getCurrentURI(request); if (uri == null) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "VelocityServlet called without running through the CMS Filter"); Logger.error(this.getClass(), "You cannot call the VelocityServlet without passing the requested url via a requestAttribute called " + Constants.CMS_FILTER_URI_OVERRIDE); return; } final boolean comeFromSomeWhere = request.getHeader("referer") != null; if (APILocator.getLoginServiceAPI().isLoggedIn(request) && !comeFromSomeWhere){ goToEditPage(uri,request, response); } else { if ((DbConnectionFactory.isMsSql() && LicenseUtil.getLevel() < LicenseLevel.PROFESSIONAL.level) || (DbConnectionFactory.isOracle() && LicenseUtil.getLevel() < LicenseLevel.PRIME.level) || (!LicenseUtil.isASAllowed())) { Logger.error(this, "Enterprise License is required"); response.sendError(HttpServletResponse.SC_NOT_FOUND); return; } final PageMode mode = PageMode.getWithNavigateMode(request); try { final String pageHtml = APILocator.getHTMLPageAssetRenderedAPI().getPageHtml( PageContextBuilder.builder() .setPageUri(uri) .setPageMode(mode) <START> .setUser(APILocator.getLoginServiceAPI().getLoggedInUser()) <END> .setPageMode(mode) .build(), request, response ); response.getOutputStream().write(pageHtml.getBytes()); } catch (ResourceNotFoundException rnfe) { Logger.error(this, "ResourceNotFoundException" + rnfe.toString(), rnfe); response.sendError(HttpServletResponse.SC_NOT_FOUND); } catch (java.lang.IllegalStateException state) { Logger.debug(this, "IllegalStateException" + state.toString()); } catch (Exception e) { if(!response.isCommitted()) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Exception Error on template"); } Logger.warnAndDebug(this.getClass(), e.getMessage(),e); } } }</code><technical_language>this is bad, if request more straight-forward solution</technical_language>

Target:
protected final void service(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException { VelocityRequestWrapper request = new VelocityRequestWrapper(req); final String uri = CMSUrlUtil.getCurrentURI(request); if (uri == null) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "VelocityServlet called without running through the CMS Filter"); Logger.error(this.getClass(), "You cannot call the VelocityServlet without passing the requested url via a requestAttribute called " + Constants.CMS_FILTER_URI_OVERRIDE); return; } final boolean comeFromSomeWhere = request.getHeader("referer") != null; if (APILocator.getLoginServiceAPI().isLoggedIn(request) && !comeFromSomeWhere){ goToEditPage(uri,request, response); } else { if ((DbConnectionFactory.isMsSql() && LicenseUtil.getLevel() < LicenseLevel.PROFESSIONAL.level) || (DbConnectionFactory.isOracle() && LicenseUtil.getLevel() < LicenseLevel.PRIME.level) || (!LicenseUtil.isASAllowed())) { Logger.error(this, "Enterprise License is required"); response.sendError(HttpServletResponse.SC_NOT_FOUND); return; } final PageMode mode = PageMode.getWithNavigateMode(request); try { final String pageHtml = APILocator.getHTMLPageAssetRenderedAPI().getPageHtml( PageContextBuilder.builder() .setPageUri(uri) .setPageMode(mode) .setUser(WebAPILocator.getUserWebAPI().getLoggedInUser(request)) .setPageMode(mode) .build(), request, response ); response.getOutputStream().write(pageHtml.getBytes()); } catch (ResourceNotFoundException rnfe) { Logger.error(this, "ResourceNotFoundException" + rnfe.toString(), rnfe); response.sendError(HttpServletResponse.SC_NOT_FOUND); } catch (java.lang.IllegalStateException state) { Logger.debug(this, "IllegalStateException" + state.toString()); } catch (Exception e) { if(!response.isCommitted()) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Exception Error on template"); } Logger.warnAndDebug(this.getClass(), e.getMessage(),e); } } }