cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Costas Matrozos <km...@istos.com>
Subject JspGenerator.java
Date Tue, 14 Oct 2003 18:39:33 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-7">
  <title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
<small><small><small><big>The following patch relates to two issues.<br>
<br>
A. (possibly a bug) <br>
    When a jsp is beeing called from within an agreegation,
'sitemapURI' is not part of the servletPath. It results to a null
pointer.<br>
    I believe it is safer to extract the 'servletPath'  by locating the
last occurance of '/'.<br>
    (has been tested and works fine)<br>
<br>
B. (suggestion. A beter way may already exists)<br>
    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.<br>
    It works just fine.<br>
<br>
rgrds<br>
costas<br>
</big><font face="Courier New, Courier, monospace"><big><br>
Index: JspGenerator.java<br>
===================================================================<br>
RCS file:
/home/cvspublic/cocoon-2.1/src/blocks/jsp/java/org/apache/cocoon/generation/JspGenerator.java,v<br>
retrieving revision 1.7<br>
diff -u -r1.7 JspGenerator.java<br>
--- JspGenerator.java   5 Sep 2003 07:04:35 -0000       1.7<br>
+++ JspGenerator.java   14 Oct 2003 18:19:38 -0000<br>
@@ -104,13 +104,21 @@<br>
                 String servletPath = httpRequest.getServletPath();<br>
                 // remove sitemap URI part<br>
                 String sitemapURI =
ObjectModelHelper.getRequest(objectModel).getSitemapURI();<br>
-                <font color="#ff0000">servletPath =
servletPath.substring(0, servletPath.indexOf(sitemapURI));</font><br>
<font color="#006600">+                try {<br>
+                  servletPath = servletPath.substring(0,
servletPath.indexOf(sitemapURI));<br>
+                } catch (Exception e) {<br>
+                  // the above statement throws an error when called
in aggregation with<br>
+                  // different name than expected<br>
+                  servletPath = servletPath.substring(0,
servletPath.lastIndexOf("/") + 1);<br>
+                }</font><br>
                 url = servletPath + url;<br>
             }<br>
                                                                                                               
 <br>
             engine = (JSPEngine)this.manager.lookup(JSPEngine.ROLE);<br>
                                                                                                               
 <br>
             getLogger().debug("JspGenerator executing JSP:" + url);<br>
+           <font color="#006600">// pass manager down to jsp.
Provides handle to DB pool<br>
+           httpContext.setAttribute("manager", manager);</font><br>
             byte[] bytes = engine.executeJSP(url, httpRequest,
httpResponse, httpContext);<br>
                                                                                                               
 <br>
             InputSource input = new InputSource(new
ByteArrayInputStream(bytes));<br>
</big></font></small></small></small><br>
</body>
</html>


Mime
View raw message