|
The following patch relates to two issues. A. (possibly a bug) When a jsp is beeing called from within an agreegation, 'sitemapURI' is not part of the servletPath. It results to a null pointer. I believe it is safer to extract the 'servletPath' by locating the last occurance of '/'. (has been tested and works fine) B. (suggestion. A beter way may already exists) My aim is to make 'manager' and more specifically the DB pool object availbe to JSP so that it can use it to make access DB. It works just fine. rgrds costas Index: JspGenerator.java =================================================================== RCS file: /home/cvspublic/cocoon-2.1/src/blocks/jsp/java/org/apache/cocoon/generation/JspGenerator.java,v retrieving revision 1.7 diff -u -r1.7 JspGenerator.java --- JspGenerator.java 5 Sep 2003 07:04:35 -0000 1.7 +++ JspGenerator.java 14 Oct 2003 18:19:38 -0000 @@ -104,13 +104,21 @@ String servletPath = httpRequest.getServletPath(); // remove sitemap URI part String sitemapURI = ObjectModelHelper.getRequest(objectModel).getSitemapURI(); - servletPath = servletPath.substring(0, servletPath.indexOf(sitemapURI)); + try { + servletPath = servletPath.substring(0, servletPath.indexOf(sitemapURI)); + } catch (Exception e) { + // the above statement throws an error when called in aggregation with + // different name than expected + servletPath = servletPath.substring(0, servletPath.lastIndexOf("/") + 1); + } url = "" + url; } engine = (JSPEngine)this.manager.lookup(JSPEngine.ROLE); getLogger().debug("JspGenerator executing JSP:" + url); + // pass manager down to jsp. Provides handle to DB pool + httpContext.setAttribute("manager", manager); byte[] bytes = engine.executeJSP(url, httpRequest, httpResponse, httpContext); InputSource input = new InputSource(new ByteArrayInputStream(bytes)); |
- Re: JspGenerator.java Costas Matrozos
- Re: JspGenerator.java Joerg Heinicke
