Closed manthanrtilva closed 8 years ago
You can use the global form object available in servlet scripts:
if (form.hasField("param"))
{
var param = form.getField("param");
}
or
var param = form.param;
Thanks that works.
Hi,
Solution given is works when i am using post/get method of AngularJS, but when i try to use rest client or HTTPPost/HTTPGet program i write using PocoNet then it doesn't works. Below is code for HTTPPost i write by modifying httpget sample of Poco/Net/
You'll need to set the content-type appropriately, or, better, use the Poco::Net::HTMLForm class to prepare the form data.
Poco::Net::HTMLForm form;
form.set("A", "B");
form.prepareSubmit(request);
std::ostream& ostr = request.send();
form.write(ostr);
I tried but no luck.
I modify my HTTPPost as below.
https://gist.github.com/manthanrtilva/e435d3559d3c644ae3ae
My devices.jss is as below. https://gist.github.com/manthanrtilva/d945d1bdbbdf949f9120
When is use above httpform with server http://www.posttestserver.com/post.php on server end request as below.
Time: Wed, 16 Dec 15 23:49:50 -0800 Source ip: 27.109.21.250
Headers (Some may be inserted by server) REQUEST_URI = /post.php QUERY_STRING = REQUEST_METHOD = POST GATEWAY_INTERFACE = CGI/1.1 REMOTE_PORT = 17796 REMOTE_ADDR = 27.109.21.250 HTTP_HOST = www.posttestserver.com HTTP_CONNECTION = close CONTENT_LENGTH = 3 CONTENT_TYPE = application/x-www-form-urlencoded UNIQUE_ID = VnJpHtBx6hIAAFLiDb4AAAAN REQUEST_TIME_FLOAT = 1450338590.1052 REQUEST_TIME = 1450338590
Post Params: key: 'A' value: 'B' Empty post body.
Upload contains PUT data: A=B
With rest client I try with many content type, but no luck with that too.
You also need to consider authentication. devices.jss requires a valid session cookie (which you get after logging in to the web interface), otherwise it will respond with 401. The check is in the first few lines. Try to remove it and see if it works.
Hi I want to pass get/post param to devices.jss from controllers.jss, so I can call setPropertyString method with user specified value. Can you guide me how i can retrieve get/post params in devices.jss