cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robin Green" <>
Subject Re: uri-include calling servlet: problems
Date Fri, 06 Oct 2000 11:20:16 GMT
"Gregory J. Grubbs" <> wrote:
>Robin's explanations have been most helpful.  I now have one of my servlets 
>being called from an XSP page and returning a reasonable result.  The
>solution seems very elegant and flexible to me.


>There are however two things which bother me about the solution:
>1) To pass the data from my HTML form using the method suggested in the 
>FAQ, I must alter the method from POST to GET, then use code like the
>  <util:include-uri>
>     <util:href>
>        <xsp:expr>"http://localhost/servlet/myServlet?" + 
>     </util:href>
>  </util:include-uri>
>Is there any way to continue using the POST method from forms, avoiding the 
>encoded URL being shown in the browser when the result returns?

That was just an example - you can use request.getParameter ("foo") or 
anything. See the Servlet API for more details. request is a 

>2) I want my middleware servlet to return a complete XML response, 
>including a specification of the stylesheet to apply.  But if the servlet
>returns the <?xml-stylesheet ... > PI, that PI will include inside the 
><page> tag... and thus confuse Cocoon, which throws the trace:
>org.apache.cocoon.processor.ProcessorException: Could not associate 
>stylesheet to document:  no matching stylesheet for: explorer
>  at 
>Compiled Code)
>  at 
>  at org.apache.cocoon.Engine.handle(, Compiled Code)
>  at org.apache.cocoon.Cocoon.service(
>  at javax.servlet.http.HttpServlet.service(
>  at 
>Compiled Code)
>  at org.apache.tomcat.core.ContextManager.service(
>  at 

>Compiled Code)
>  at 
>Compiled Code)
>  at, Compiled Code)
>Is there any clever way of applying a stylesheet specified by the servlet's 
>return value?

I would suggest.

A) Don't return a processing instruction, but instead a normal XML element, 
say <stylesheet-url>.

B) After the <util:include-uri> tag has executed, the xspCurrentNode 
variable will point to the parent element of the inserted file (not the root 
element of the inserted file but the parent of that). You can then use the 
DOM API to walk down, take out the <stylesheet-url> element and insert an 
xml-stylesheet processing instruction as a child of the document with 
document.appendChild (it has to be at the top level or Cocoon won't 
recognise it).

or you could use stylesheet-chaining instead of B, maybe simpler but less 
efficient I would think.

Get Your Private, Free E-mail from MSN Hotmail at

Share information about yourself, create your own public profile at

View raw message