cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gelo1234 <>
Subject Re: calling a sitemap-snippet from within a program
Date Fri, 21 Mar 2014 08:53:19 GMT

1. Yes, it's possible. Since all sitemap matching URL's are actually kind
of HTTP Servlets, you can just use any http client (e.g. Apache HttpClient)
to invoke the servlet and get the response (if that is outside Cocoon):

HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet("");
HttpResponse response = client.execute(request);
*// Get the response*
BufferedReader rd = new BufferedReader
  (new InputStreamReader(response.getEntity().getContent()));

String line = "";while ((line = rd.readLine()) != null) {

2. You can invoke any sitemap-servlet from within cocoon pipeline of course:

3. If you want to invoke sitemap-servlet from Cocoon API, first you need to
decide at which step that action need to be taken. If it's a Starter, you
can use XMLGenerator with given URL:

URL base = this.getClass().getResource("");
Pipeline<SAXPipelineComponent> pipeline = new
pipeline.addComponent(new XMLGenerator(new URL(base, "servlet.xml")));

If it's somewhere in the middle of the pipeline, you can use
IncludeTransformer that will call your servlet-service:

pipeline.addComponent(new XIncludeTransformer("servlet_calling_include.xml"));




Hope that helps.


2014-03-21 9:14 GMT+01:00 Yahoo <>:

> Hello Greg,
> is it possible  to call a sitemap-snippet within a program an getting the
> respone inside a program?
> H.Braun
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

View raw message