cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robin Green" <gree...@hotmail.com>
Subject Re: uri-include calling servlet: problems
Date Fri, 06 Oct 2000 11:20:16 GMT
"Gregory J. Grubbs" <bulk@hoochiepep.com> 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
>following:
>  <util:include-uri>
>     <util:href>
>        <xsp:expr>"http://localhost/servlet/myServlet?" + 
>request.getQueryString()</xsp:expr>
>     </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 
HttpServletRequest.

>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 
>org.apache.cocoon.processor.xslt.XSLTProcessor.getResource(XSLTProcessor.java, 
>Compiled Code)
>  at 
>org.apache.cocoon.processor.xslt.XSLTProcessor.process(XSLTProcessor.java:107)
>  at org.apache.cocoon.Engine.handle(Engine.java, Compiled Code)
>  at org.apache.cocoon.Cocoon.service(Cocoon.java:167)
>  at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>  at 
>org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java, 
>Compiled Code)
>  at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
>  at 
>org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java,

>Compiled Code)
>  at 
>org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java, 
>Compiled Code)
>  at java.lang.Thread.run(Thread.java, 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 http://www.hotmail.com.

Share information about yourself, create your own public profile at 
http://profiles.msn.com.


Mime
View raw message