cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joerg Heinicke <jheini...@virbus.de>
Subject Re: JspGenerator.java
Date Tue, 14 Oct 2003 23:33:30 GMT
On 14.10.2003 20:39, Costas Matrozos wrote:

> 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)

working on it.

> 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.

I don't like the idea. You leave the Cocoon world, but want to provide a 
Cocoon object to the outside? Can somebody else comment?

Joerg

> 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 = servletPath + 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));
> 


Mime
View raw message