AnsweredAssumed Answered

Problem getting parameters in web script

Question asked by spilby on May 13, 2014
Latest reply on May 14, 2014 by spilby

I don't know why I can't obtain a parameter in my java backed web script.

I do this to call my java backed webscript by REST:

   HttpClient client = new HttpClient(); 
   PostMethod method = new PostMethod("http://IP/alfresco/service/mywebscript");

   // 2 ways to set de parameter. No one works!
   client.getParams().setParameter("name", "George");
   method.setParameter("name", "George");

   int statusCode = client.executeMethod(method);  

And on the java webscript side, I would to obtain the parameter doing this:

   public void execute(WebScriptRequest req, WebScriptResponse res) throws WebScriptException
    String param =  req.getParameter("name")

But the param is null! What I'm doing wrong??

If I call the url throw the Firefox, doing "http://IP/alfresco/service/mywebscript?name=George" the param isn't null and arrives George. And if I do

   PostMethod method = new PostMethod("http://IP/alfresco/service/mywebscript?name=George");

it works fine too. Why don't works using the setParameter?? I don't understand.

Thanks a lot!