You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Xavier MACHENAUD <xa...@st.com> on 2001/06/12 10:54:34 UTC

[C1] Posting parameters to a servlet

Using C1, I can call a servlet passing parameters with an HTTP GET using
the following code :

  <util:include-uri>
    <util:href>
      <xsp:expr>
        "http://<server>/<servlet-uri>?" +
        "techno=" + request.getParameter("techno") + "&amp;" +
        "volt="   + request.getParameter("volt")   + "&amp;" +
        "arch="   + request.getParameter("arch")   + "&amp;" +
        "words="  + request.getParameter("words")  + "&amp;" +
        "bits="   + request.getParameter("bits")   + "&amp;"
      </xsp:expr>
    </util:href>
  </util:include-uri>

I can then transform the returned XML data to present it to the user.


But how can I do the same thing but passing parameters with an HTTP
POST?
I need this to be able to send a file to a servlet.

Thanks.

Xavier

---------------------------------------------------------------------
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: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: [C1] Posting parameters to a servlet

Posted by Sylvain Wallez <sy...@anyware-tech.com>.

Xavier MACHENAUD a écrit :
> 
> Using C1, I can call a servlet passing parameters with an HTTP GET using
> the following code :
> 
>   <util:include-uri>
>     <util:href>
>       <xsp:expr>
>         "http://<server>/<servlet-uri>?" +
>         "techno=" + request.getParameter("techno") + "&amp;" +
>         "volt="   + request.getParameter("volt")   + "&amp;" +
>         "arch="   + request.getParameter("arch")   + "&amp;" +
>         "words="  + request.getParameter("words")  + "&amp;" +
>         "bits="   + request.getParameter("bits")   + "&amp;"
>       </xsp:expr>
>     </util:href>
>   </util:include-uri>
> 
> I can then transform the returned XML data to present it to the user.
> 
> But how can I do the same thing but passing parameters with an HTTP
> POST?
> I need this to be able to send a file to a servlet.
> 
> Thanks.
> 
> Xavier
> 
The answer is unfortunately simple : you can't POST using
<util:include-uri> !
You'll have to write code that does the POST using a
java.net.HttpURLConnection and parse its result for inclusion into the
document.
-- 
Sylvain Wallez
Anyware Technologies - http://www.anyware-tech.com

---------------------------------------------------------------------
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: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>