You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Bernhard Huber <be...@a1.net> on 2002/04/21 12:36:15 UTC

[announcement] JSP, Servlet2.3 Filter CocoonFilterGeneratorImpl, and RequestAttributeGenerator

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: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: [announcement] JSP, Servlet2.3 Filter CocoonFilterGeneratorImpl,and RequestAttributeGenerator

Posted by Bernhard Huber <be...@a1.net>.
>
>
>I'm pretty damn sure that people will abuse this, but some others might
>find interesting uses of it.
>
In my oppinion this the only Servlet 2.3 conformant way for having JSP 
generating XML, and using
Cocoon for reendering!
I'm not 100% sure if the CocoonFilterGeneratorImpl approach of creating 
its own Cocoon servlet instance
is the best way, so if there are some other suggestion....

>
>
>Bring it on!
>
done

>
bye bernhard



---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: [announcement] JSP, Servlet2.3 Filter CocoonFilterGeneratorImpl,and RequestAttributeGenerator

Posted by Stefano Mazzocchi <st...@apache.org>.
Bernhard Huber wrote:
> 
> 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.

Sounds like a cool feature.

I'm pretty damn sure that people will abuse this, but some others might
find interesting uses of it.

Bring it on!

-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<st...@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org