kpiroumian 02/04/22 02:47:51 Modified: src/java/org/apache/cocoon/generation JspGenerator.java Log: Allow relative paths in sitemap. Fixes: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=2631 Revision Changes Path 1.7 +14 -10 xml-cocoon2/src/java/org/apache/cocoon/generation/JspGenerator.java Index: JspGenerator.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/generation/JspGenerator.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- JspGenerator.java 22 Feb 2002 07:03:51 -0000 1.6 +++ JspGenerator.java 22 Apr 2002 09:47:51 -0000 1.7 @@ -74,7 +74,7 @@ * results into SAX events. * * @author <a href="mailto:[EMAIL PROTECTED]">Davanum Srinivas</a> - * @version CVS $Id: JspGenerator.java,v 1.6 2002/02/22 07:03:51 cziegeler Exp $ + * @version CVS $Id: JspGenerator.java,v 1.7 2002/04/22 09:47:51 kpiroumian Exp $ */ public class JspGenerator extends ServletGenerator implements Configurable { @@ -101,22 +101,27 @@ JSPEngine engine = null; Parser parser = null; - Source src = null; try { - src = this.resolver.resolve(this.source); - String url = src.getSystemId(); - // Guarantee src parameter is a file - if (!url.startsWith("file:/")) - throw new IOException("Protocol not supported: " + url); + // FIXME (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 file part + servletPath = servletPath.substring(0, servletPath.lastIndexOf('/') + 1); + url = servletPath + url; + } + + engine = (JSPEngine)this.manager.lookup(JSPEngine.ROLE); - url = url.substring(5); getLogger().debug("JspGenerator executing JSP:" + url); - engine = (JSPEngine)this.manager.lookup(JSPEngine.ROLE); byte[] bytes = engine.executeJSP(url, httpRequest, httpResponse, httpContext); // explicitly specify bytestream encoding InputSource input = new InputSource(new ByteArrayInputStream(bytes)); + // FIXME (KP): Why do we need this? input.setEncoding("utf-8"); // pipe the results into the parser @@ -139,7 +144,6 @@ getLogger().debug("Exception in JspGenerator.generate()", e); throw new ProcessingException("Exception JspGenerator.generate()",e); } finally { - if (src != null) src.recycle(); this.manager.release(parser); this.manager.release(engine); }
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]