Return-Path: Mailing-List: contact cocoon-users-help@xml.apache.org; run by ezmlm Delivered-To: mailing list cocoon-users@xml.apache.org Received: (qmail 87233 invoked from network); 9 Nov 2000 20:00:47 -0000 Received: from nat161.speedtrak.com (HELO taxi.speedtrak.com) (216.233.222.161) by locus.apache.org with SMTP; 9 Nov 2000 20:00:47 -0000 Received: from kojak.speedtrak.com (IDENT:root@kojak.speedtrak.com [192.168.1.49]) by taxi.speedtrak.com (8.10.0/8.10.0) with ESMTP id eA9K0Jb03105 for ; Thu, 9 Nov 2000 12:00:19 -0800 Received: from speedtrak.com (IDENT:1024@localhost.localdomain [127.0.0.1]) by kojak.speedtrak.com (8.9.3/8.9.3) with ESMTP id MAA13677 for ; Thu, 9 Nov 2000 12:00:19 -0800 Sender: mala@speedtrak.com Message-ID: <3A0B0253.1BAD3B10@speedtrak.com> Date: Thu, 09 Nov 2000 12:00:19 -0800 From: Mala Ramakrishnan X-Mailer: Mozilla 4.72 [en] (X11; U; Linux 2.2.14-5.0smp i686) X-Accept-Language: en MIME-Version: 1.0 To: cocoon-users@xml.apache.org Subject: URLProducer: Redirecting Servlet generated pages to Cocoon Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N Hi, I found exactly what I need in one of the mails from the archive. I need to convert the output xml of a servlet to html and to do this, an example of a URLProducer is what I found. However, I am a bit confused about the usage that has been explained and will be thankful if someone can throw some light on it. The usage of the example URLProducer given below is as follows: http://www.myserver.com/apage.xml?producer=URLProducer&xmlSource=http://www.client.com/tablevalues?table_name=client_table What would apage.xml be? I am appending the email discussion for context. Thanks, Mala ------------------- Original Message ---------------- Its so exciting when I can contribute, rather than always asking questions! I was tasked with the same project. 1. I created a servlet which would take select statement parameters, and return the results in .XML. 2. Created a "URL Producer" (see docs on producers) which would access the URL, get the XML, combine it with the XSL, then return HTML to the client. Here is the code I used for the URL Producer To use it, pass the url which provides the xml source as a parameter called xmlSource. For example, in my setup, I call: http://www.myserver.com/apage.xml?producer=URLProducer&xmlSource=http://www. client.com/tablevalues?table_name=client_table Please feel free to modify this. I am a "hobbyist" programmer, so I am sure this could be improved. package org.apache.cocoon.producer; import java.io.*; import java.net.*; import java.util.*; import javax.servlet.http.*; import org.apache.cocoon.*; import org.apache.cocoon.framework.*; /** * This class implements the producer interface in order to produce a document * based on a provided URL. This code was shamlessly built upon the shoulders of * sample files created by Stefano Mazzocchi. * * the url used is passed by parameter "xmlSource=http://www.webserver.org/filename?arg1=x&arg2=y..." * * @author Steve Belt * */ public class URLProducer extends AbstractProducer implements Status { public Reader getStream(HttpServletRequest request) throws IOException { String urlString=request.getQueryString(); // get the URL information // this must be parsed out as the "&" in any passed parameters cause the url to gag for(int j=0;j<=urlString.length()-12; j++) if ( urlString.substring(j,j+9).compareTo("xmlSource")==0) urlString=urlString.substring(j+10); file://expects parameter ...xmlSource=http://... without surrounding quotes URL xmlSourceURL = new URL(urlString); BufferedReader in = new BufferedReader(new InputStreamReader(xmlSourceURL.openStream() ) ); String inputLine; String xmlbuffer=""; while( (inputLine = in.readLine() ) != null) xmlbuffer=xmlbuffer+inputLine; in.close(); return new StringReader(xmlbuffer); } public String getPath(HttpServletRequest request) { return ""; } public String getStatus() { return "URL Producer"; } } ---- Original Message ----- From: Wolfgang Werner To: Sent: Monday, January 03, 2000 10:46 AM Subject: Redirecting JSP or Servlet generated pages to cocoon > Hi there, > > I'm looking for infos. I need to generate XML files by jsp files or > servlets (ok, basically the same), for instance becaus I need to > retrieve the xml content from a database, and want to redirect > theses generated xml pages to cocoon. > > What do I have to do? Is there an how-to or article? > > Thanks in advcance, > > Wolfgang Werner >