Examples of JSPEngine


Examples of org.apache.cocoon.components.jsp.JSPEngine

        // ensure that we are running in a servlet environment
        if (servletResponse == null || servletRequest == null || servletContext == null) {
            throw new ProcessingException("JSPGenerator can only be used from within a Servlet environment.");
        }

        JSPEngine engine = null;
        SAXParser parser = null;
        Source inputSource = null;
        Source contextSource = null;
        try {
            inputSource = this.resolver.resolveURI(this.source);
            contextSource = this.resolver.resolveURI("context:/");

            String inputSourceURI = inputSource.getURI();
            String contextSourceURI = contextSource.getURI();

            if (!inputSourceURI.startsWith(contextSourceURI)) {
                throw new ProcessingException("You must not reference a file "
                        + "outside of the servlet context at " + contextSourceURI + ".");
            }

            String url = inputSourceURI.substring(contextSourceURI.length());
            if (url.charAt(0) != '/') {
                url = "/" + url;
            }

            if (getLogger().isDebugEnabled()) {
                getLogger().debug("JSPGenerator executing:" + url);
            }

            engine = (JSPEngine) super.manager.lookup(JSPEngine.ROLE);
            byte[] bytes = engine.executeJSP(url, servletRequest, servletResponse, servletContext);

            InputSource input = new InputSource(new ByteArrayInputStream(bytes));
            // utf-8 is default encoding; specified explicitely here as a reminder.
            input.setEncoding("utf-8");
View Full Code Here

Examples of org.apache.cocoon.components.jsp.JSPEngine

        // ensure that we are running in a servlet environment
        if (servletResponse == null || servletRequest == null || servletContext == null) {
            throw new ProcessingException("JSPGenerator can only be used from within a Servlet environment.");
        }

        JSPEngine engine = null;
        SAXParser parser = null;
        Source inputSource = null;
        Source contextSource = null;
        try {
            inputSource = this.resolver.resolveURI(this.source);
            contextSource = this.resolver.resolveURI("context:/");

            String inputSourceURI = inputSource.getURI();
            String contextSourceURI = contextSource.getURI();

            if (!inputSourceURI.startsWith(contextSourceURI)) {
                throw new ProcessingException("You must not reference a file "
                        + "outside of the servlet context at " + contextSourceURI + ".");
            }

            String url = inputSourceURI.substring(contextSourceURI.length());
            if (url.charAt(0) != '/') {
                url = "/" + url;
            }

            if (getLogger().isDebugEnabled()) {
                getLogger().debug("JSPGenerator executing:" + url);
            }

            engine = (JSPEngine) super.manager.lookup(JSPEngine.ROLE);
            byte[] bytes = engine.executeJSP(url, servletRequest, servletResponse, servletContext);

            InputSource input = new InputSource(new ByteArrayInputStream(bytes));
            // utf-8 is default encoding; specified explicitely here as a reminder.
            input.setEncoding("utf-8");
View Full Code Here

Examples of org.apache.cocoon.components.jsp.JSPEngine

        // ensure that we are running in a servlet environment
        if (servletResponse == null || servletRequest == null || servletContext == null) {
            throw new ProcessingException("JSPReader can only be used from within a Servlet environment.");
        }

        JSPEngine engine = null;
        Source inputSource = null;
        Source contextSource = null;
        try {
            inputSource = this.resolver.resolveURI(this.source);
            contextSource = this.resolver.resolveURI("context:/");

            String inputSourceURI = inputSource.getURI();
            String contextSourceURI = contextSource.getURI();

            if (!inputSourceURI.startsWith(contextSourceURI)) {
                throw new ProcessingException("You must not reference a file "
                        + "outside of the servlet context at " + contextSourceURI + ".");
            }

            String url = inputSourceURI.substring(contextSourceURI.length());
            if (url.charAt(0) != '/') {
                url = "/" + url;
            }

            if (getLogger().isDebugEnabled()) {
                getLogger().debug("JSPReader executing:" + url);
            }

            engine = (JSPEngine) super.manager.lookup(JSPEngine.ROLE);
            byte[] bytes = engine.executeJSP(url, servletRequest, servletResponse, servletContext);

            if (this.outputEncoding != null) {
                recodeResult (bytes, this.outputEncoding);
            } else {
                out.write(bytes);
View Full Code Here

Examples of org.apache.cocoon.components.jsp.JSPEngine

        if (httpResponse == null || httpRequest == null || httpContext == null) {
            throw new ProcessingException("HttpServletRequest or HttpServletResponse or ServletContext object not available");
        }

        JSPEngine engine = null;
        SAXParser parser = null;
        try {
            // TODO (KP): Should we exclude not supported protocols, say 'context'?
            String url = this.source;
            // absolute path is processed as is
            if (!url.startsWith("/")) {
                // get current request path
                String servletPath = httpRequest.getServletPath();
                // remove sitemap URI part
                String sitemapURI = ObjectModelHelper.getRequest(objectModel).getSitemapURI();
                servletPath = servletPath.substring(0, servletPath.indexOf(sitemapURI));
                url = servletPath + url;
            }

            engine = (JSPEngine)this.manager.lookup(JSPEngine.ROLE);

            getLogger().debug("JspGenerator executing JSP:" + url);
            byte[] bytes = engine.executeJSP(url, httpRequest, httpResponse, httpContext);

            InputSource input = new InputSource(new ByteArrayInputStream(bytes));
            // utf-8 is default encoding; specified explicitely here as a reminder.
            input.setEncoding("utf-8");
View Full Code Here

Examples of org.apache.cocoon.components.jsp.JSPEngine

        if (httpResponse == null || httpRequest == null || httpContext == null) {
            throw new ProcessingException("JSPReader can be used only in a Servlet/JSP environment");
        }

        JSPEngine engine = null;
        try {
            // TODO (KP): Should we exclude not supported protocols, say 'context'?
            String url = this.source;

            // absolute path is processed as is
            if (!url.startsWith("/")) {
                // get current request path
                String servletPath = httpRequest.getServletPath();
                // remove sitemap URI part
                String sitemapURI = ObjectModelHelper.getRequest(objectModel).getSitemapURI();
                servletPath = servletPath.substring(0, servletPath.indexOf(sitemapURI));
                url = servletPath + url;
            }

            engine = (JSPEngine)this.manager.lookup(JSPEngine.ROLE);

            if (this.getLogger().isDebugEnabled()) {
                this.getLogger().debug("JSPReader executing JSP:" + url);
            }

            byte[] bytes = engine.executeJSP(url, httpRequest, httpResponse, httpContext);
            // TODO (KP): Make buffer size configurable
            byte[] buffer = new byte[8192];
            int length = -1;

            // TODO: Recode from UTF8 to desired output encoding.
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.