How to access the request parameters? [message #1843005] |
Sat, 10 July 2021 16:12  |
Eclipse User |
|
|
|
Hello
I would like to use the request parameters from the RAP FAQ (https://wiki.eclipse.org/RAP/FAQ#How_to_access_the_request_parameters.3F )
When it is called directly from the browser, it performs normal.
However, calling Curl, HTTP Client, or RestClient does not produce results. What should I do?
Please help me.
Test code
try {
HttpClient httpclient = HttpClients.createDefault();
HttpPost httpget = new HttpPost("http://127.0.0.1:8080/main/?testUID=402baba0-2683-49fc-9881-5e038972d48a&&method=PreferenceInitialize");
httpget.setHeader("Accept", "application/json");
httpget.setHeader("Content-type", "application/json");
httpget.setHeader("Cache-Control", "no-cache");
httpget.setHeader("Content-type", "no-store");
httpget.setHeader("Content-type", "private");
httpget.setHeader("Pragma", "no-chache");
// Request parameters and other properties.
List<NameValuePair> params = new ArrayList<NameValuePair>(2);
params.add(new BasicNameValuePair("testUID", "402baba0-2683-49fc-9881-5e038972d48a"));
params.add(new BasicNameValuePair("method", "PreferenceInitialize"));
httpget.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
//Execute and get the response.
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
if (entity != null) {
InputStream instream = entity.getContent();
try {
// do something useful
} finally {
instream.close();
}
}
} catch(Exception e) {
e.printStackTrace();
}
[Updated on: Sat, 10 July 2021 16:16] by Moderator Report message to a moderator
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03506 seconds