Hi,

I'm using a java client to interact with cocoon like this :

 String query =  "SrvImpCtx=1";
    query += "&SrvImpNombreCopies=1";
    query += "&SrvImpOrigine=1";
    query += "&SrvImpTypeRequete=ENREGISTRER";
    query += "&SrvImpNomPdf=1";
    query += "&SrvImpUrlCallback=1";
    query += "&SrvImpCtxCallback=1";

 URL myUrl = new URL(PARA_URL);
 java.net.HttpURLConnection con =
(java.net.HttpURLConnection)myUrl.openConnection();
 con.setRequestMethod("POST");
 con.setDoInput(true);
 con.setDoOutput(true);
 con.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
 con.connect();

 con.getOutputStream().write(query.getBytes());
 con.getOutputStream().close();

/* if(con.getResponseCode () != 200)
 {
  throw new Exception("error");
 }
*/
 System.out.println(con.getResponseCode());
 InputStream is = con.getInputStream ();
 int c;
 while((c=is.read())!=-1)
{
WHAT YOU WANT
}

is.close();


----- Original Message -----
From: "Skladovs, Victor" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, November 08, 2002 9:42 AM
Subject: REPEATED:HELP!!!: Pass parameters from applet to cocoon with POST
and receive HTML Page back


Hi to all!

I sent this question with a help cry yesterday but nobody replied -:(((
Does the silence of the group mean that nobody has faced this problem so
far?

Anyway, I'll try one more time.

My goal is to pass the parameters from an applet to cocoon with POST
method and receive a HTML Page back. I haven't managed to get this so
far :-(

What I've done:
1) In my applet:

URL url = new URL("http://myserver.de/cocoon/page.html";);
URLConnection connection = url.openConnection();
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type","text/html");
PrintWriter out = new
PrintWriter(connection.getOutputStream());
out.print("user=" + URLEncoder.encode("user") + "&");
out.print("password=" + URLEncoder.encode("password"));
out.close();

This is of course only a example: if it was only for these two
parameters, I would pass them with GET method:
applet.getAppletContext().showDocument(
"http://myserver.de/cocoon/page.html?user=user&password=password";);

It works perfect. But actually I'd like to pass to cocoon a vector with
parameters.

2) In my sitemap.xmap :

<map:match pattern="page.html">
<map:generate
src="docs/samples/xsp/page.xsp" type="serverpages"/>
<map:transform
src="stylesheets/xml2html.xsl">
<map:parameter
name="view-source" value=" docs/samples/xsp/page.xsp"/>
</map:transform>
<map:serialize/>
</map:match>


3)my page.xsp:

<xsp:page language="java" xmlns:xsp="http://apache.org/xsp";
xmlns:xsp-request="http://apache.org/xsp/request/2.0";
xmlns:esql="http://apache.org/cocoon/SQL/v2";>
<page title="My HTML Page" bgcolor="#FFFFC0">
<table>
<tr>
<td>
<p align="left">

<xsp-request:get-parameter name="user"/>
</p>
<p align="left">

<xsp-request:get-parameter name="password"/>
</p>
</td>
</tr>
</table>
</page>
</xsp:page>



4) Again in applet :

If I open BefferedReader (only to test), I can see that
cocoon has really done
his job - the HTML page exists, I can read it as a String in my
Java-Console , but I don't see it in my browser!!!

           BufferedReader in = new BufferedReader(new
InputStreamReader(connection.getInputStream()));
    String line;
            while((line = in.readLine()) != null){
                System.out.println(line);
            }
            in.close();

QUESTION: What have I done wrong? What do I have to do to get my
HTML Page be seen in browser?

Thanks to all in advance!

Viktor


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.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/faq/index.html>

To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>

Reply via email to