hi, folks

Intro
as i could not make JSPEngine working under WLS6.1,
i choose a different approach which is more general and
ASFAIK servlet 2.3 conformant.

I implemented a servlet 2.3 filter CocoonFilterGeneratorImpl.
This filter processes all entries of the filter chain first, and
save the response in a local response.
As final step a cocoon servlet instance services the
original request, having the local response as request-attribute.
A RequestAttributeGenerator pipes the value of the request-attribute
into the Cocoon pipeline.
RequestAttributeGenerator is more or less like StreamGenerator.

The cocoon servlet instance uses the original response for sending
response to the client.

As a consequence each filter instance initializes/destroyes its own 
cocoon servlet instance.

Now this kind of approach is not limited to processing JSP, but you may
define any servlet, or other filters as pre-processing steps of this filter.

I think this is the only Servlet 2.3 conformant way to process JSP 
output in Cocoon.

Names & Commits

I will commit the filter as 
org.apache.cocoon.servlet.CocoonFilterGeneratorImpl,
and org.apache.cocoon.generation.RequestAttributeGenerator into scratchpad.

Moreover CocoonFilterGeneratorImpl explains how-to setup your web.xml, 
and your
sitemap.xmap.

Configuration snippet for web.xml
  ...
  <filter>
    <filter-name>CocoonFilterGenerator</filter-name>
    <display-name>CocoonFilterGenerator</display-name>
    <description>Run JSP/Servlet processing before feeding into 
Cocoon</description>
    
<filter-class>org.apache.cocoon.servlet.CocoonFilterGeneratorImpl</filter-class>
    <init-param>
      <param-name>cocoon-servlet-class-name</param-name>
      <param-value>org.apache.cocoon.servlet.CocoonServlet</param-value>
    </init-param>
  </filter>

  <filter-mapping>
    <filter-name>CocoonFilterGenerator</filter-name>
    <url-pattern>*.jsp</url-pattern>
  </filter-mapping>
  <servlet>
...
  <!--
  <servlet-mapping>
    <servlet-name>Cocoon2</servlet-name>
    <url-pattern>*.jsp</url-pattern>
  </servlet-mapping>
  -->

Note by default jsp files are handled by the JSP servlet.
Cocoon servlet does not need to get mapped to *.jsp anymore.

Configuration snippet for sittemap.xmap:
...
   <map:match pattern="docs/samples/jsp/*">
    <map:generate type="req-attr"/>
    <!--map:generate src="docs/samples/jsp/{1}.jsp" type="jsp"/-->

    <map:transform src="stylesheets/page/simple-page2html.xsl">
        <map:parameter name="view-source" value="docs/samples/jsp/{1}.jsp"/>
    <!--
       Run-time configuration is done through these
       <map:parameter/> elements. Again, let's have a look at the
       javadocs:

       "[...] All <map:parameter> declarations will be made
       available in the XSLT stylesheet as xsl:variables. [...]"
    -->
    </map:transform>
   
    <map:transform type="log"/>
   
    <map:serialize/>
   </map:match>
...
Note: You must use the request URI, as matching is already done by the 
servlet container,
thus the original sitemap JSP sample matching="jsp/*" will not work.

bye bernhard



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to