I had the same problem some time ago, and I wasn't able to do it using Cocoon, finally, I created and intermediate servlet which receives my parameters (using GET) and uses the functions of the URLConection java class (see the api docs), to connect with the desired external servlet. With this class, you can 'read' the URL (get the result page) or 'write' to the URL, this means forwarding the parameters using POST. See an example that works on my server:
String XML=the parameter URL miurl = new URL("http://www.WHATEVER.es/cgi-bin/XMLPROCESS"); URLConnection con = miurl.openConnection(); con.setDoOutput(true); con.setDoInput(true); con.setUseCaches(false); con.setRequestProperty("Content-type","application/x-www-form-urlencoded ; charset=ISO-8859-1"); con.setRequestProperty("Content-length", "" + URLEncoder.encode(XML) ); DataOutputStream dos = new DataOutputStream(con.getOutputStream()); dos.writeBytes("XML=" + URLEncoder.encode(XML)); dos.close(); .... BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); String linea; String todo=""; while ((linea=in.readLine())!= null) todo= todo + linea; in.close(); If you find any other way to do it, please, refer it to me ! bye -----Mensaje original----- De: Andreas Hartmann [mailto:[EMAIL PROTECTED]] Enviado el: lunes, 14 de enero de 2002 14:22 Para: [EMAIL PROTECTED] Asunto: RE: How to call an external Servlet? Hi Lukas, thanks for your answer, but ... [see below] *********** REPLY SEPARATOR *********** On 14.01.2002 at 11:59 lucas wrote: >just type the name of the external servlet in your sitemap pipeline, >adding >the parameters. >in example, if you want to call a servlet called 'outserv' and give it two >parameters, 'X' and 'Y', you can do something like this: > ><map:match pattern="outserv"> > <map:act type="request"> > <map:parameter name="parameters" value="true"/> > <map:generate >src="http://www.something.com/outserv?X={X}&Y={Y}" /> ></map:act> > <map:serialize type="html"/> ></map:match> > > >Here, you submit the parameters given to cocoon to the external servet with >the GET method. I dont't know how to do it directly with POST method, but This is exactly my problem. With GET everything works fine, but I couldn't find a way to pass parameters by POST. I don't want to set the parameters in the sitemap, I want to "forward" the parameters from an HTML form (it's a message board servlet). >this one works fine if GET method is available. >beware to use '&' instead of '&' > > >-----Mensaje original----- >De: Andreas Hartmann [mailto:[EMAIL PROTECTED]] >Enviado el: domingo, 13 de enero de 2002 18:37 >Para: [EMAIL PROTECTED] >Asunto: How to call an external Servlet? > > >Hi folks, > >I want to process the output of an external servlet through C2. >The servlet gets FORM-parameters via GET and POST. >How can I invoke the servlet? > >Thanks in advance, >Andreas > > >--------------------------------------------------------------------- >Please check that your question has not already been answered in the >FAQ before posting. <http://xml.apache.org/cocoon/faqs.html> > >To unsubscribe, e-mail: <[EMAIL PROTECTED]> >For additional commands, e-mail: <[EMAIL PROTECTED]> --------------------------------------------------------------------- Please check that your question has not already been answered in the FAQ before posting. <http://xml.apache.org/cocoon/faqs.html> To unsubscribe, e-mail: <[EMAIL PROTECTED]> For additional commands, e-mail: <[EMAIL PROTECTED]> --------------------------------------------------------------------- Please check that your question has not already been answered in the FAQ before posting. <http://xml.apache.org/cocoon/faqs.html> To unsubscribe, e-mail: <[EMAIL PROTECTED]> For additional commands, e-mail: <[EMAIL PROTECTED]>