You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Wolfgang Werner <ww...@picturesafe.de> on 2000/01/03 19:46:39 UTC

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

	Picture/Safe Media Data Bank GmbH
	Großer Burstah 36-38
	20457 Hamburg

	eMail		wwerner@picture-safe.de
	Telefon	+49 (0)40 / 37 41 27 - 81
	Telefax	+49 (0)40 / 37 41 27 - 99


Re: Redirecting JSP or Servlet generated pages to cocoon

Posted by Kuntal Trivedi <ku...@tatainfotech.com>.
I'm using JRun on IIS, and Cocoon 1.5
I want to know where to place the URLProducer.class file in the JRun
directory.
I placed it in the jrun/jsm-default/classes , jrun/classes directory but no
luck!
Do I specify the package name in the cocoon.prperties file as
    producer.type.XXX=org.apache.cocoon.producer.XXX
or just
    producer.type.XXX=XXX
Either way, i get an error saying that it cannot find the class file
Please, can someone help me out
Also, what processing instruction should the xml file contain in order to be
able to use URLProducer
<?cocoon-....?>

Thanks


----- Original Message -----
From: Steve Belt <sb...@VELOS.COM>
To: <co...@xml.apache.org>
Sent: Tuesday, January 04, 2000 3:55 AM
Subject: Re: Redirecting JSP or Servlet generated pages to cocoon


> 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.
>
> (note: Remember to define the producer in the .conf file)
>
> <begin>
>
> 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 <a href="mailto:sbelt@velos.com">Steve Belt</a>
>  *
>  */
>
> 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 <ww...@picturesafe.de>
> To: <co...@xml.apache.org>
> 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
> >
> > Picture/Safe Media Data Bank GmbH
> > Großer Burstah 36-38
> > 20457 Hamburg
> >
> > eMail wwerner@picture-safe.de
> > Telefon +49 (0)40 / 37 41 27 - 81
> > Telefax +49 (0)40 / 37 41 27 - 99
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> > For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
> ----- Original Message -----
> From: Wolfgang Werner <ww...@picturesafe.de>
> To: <co...@xml.apache.org>
> 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
> >
> > Picture/Safe Media Data Bank GmbH
> > Großer Burstah 36-38
> > 20457 Hamburg
> >
> > eMail wwerner@picture-safe.de
> > Telefon +49 (0)40 / 37 41 27 - 81
> > Telefax +49 (0)40 / 37 41 27 - 99
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> > For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org


Re: Redirecting JSP or Servlet generated pages to cocoon

Posted by Steve Belt <sb...@VELOS.COM>.
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.

(note: Remember to define the producer in the .conf file)

<begin>

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 <a href="mailto:sbelt@velos.com">Steve Belt</a>
 *
 */

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 <ww...@picturesafe.de>
To: <co...@xml.apache.org>
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
>
> Picture/Safe Media Data Bank GmbH
> Großer Burstah 36-38
> 20457 Hamburg
>
> eMail wwerner@picture-safe.de
> Telefon +49 (0)40 / 37 41 27 - 81
> Telefax +49 (0)40 / 37 41 27 - 99
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org

----- Original Message -----
From: Wolfgang Werner <ww...@picturesafe.de>
To: <co...@xml.apache.org>
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
>
> Picture/Safe Media Data Bank GmbH
> Großer Burstah 36-38
> 20457 Hamburg
>
> eMail wwerner@picture-safe.de
> Telefon +49 (0)40 / 37 41 27 - 81
> Telefax +49 (0)40 / 37 41 27 - 99
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org