I am trying to open a link in default browser. I have used the following code.
try {
HttpPost httpPost;
httpPost = new HttpPost(
"https://evolven.wlb4.apac.nsroot.net:8441/enlight.server/html/scripts/api/assets.jsp?action=table&all=true&"
+ "envId=92738683&globalCrit=Host%20where%20name:sdcgcgtiblb20pv%20|"
+ "%20Certificates%20where%20Until%3E1d%20AND%20Until%3C31d%20&%20EvolvenSessionKey="+id+"&json=true");
//httpPost.setEntity(new StringEntity(data));
httpPost.setHeader("Accept", "application/json");
httpPost.setHeader("Content-type", "application/json");
CloseableHttpResponse response = client.execute(httpPost);
if (response.getStatusLine().getStatusCode() == 200) {
BufferedReader br = new BufferedReader(new InputStreamReader((response.getEntity().getContent())));
String output;
while ((output = br.readLine()) != null) {
responseData = responseData + output;
}
} else {
responseData = "{\"status\": \"ERROR\"}";
}
I am trying to open a link in default browser. I have used the following code.
String myUrl = "http://www.example.com/engine/myProcessor.jsp?Type=A Type&Name=1100110&Char=!";
try {
Desktop.getDesktop().browse(new URI(myUrl));
} catch (IOException err) {
setTxtOutput("Error: "+err.getMessage());
} catch (URISyntaxException err) {
setTxtOutput("Error: "+err.getMessage());
} catch (Exception err) {
setTxtOutput("Error: "+err.getMessage());
}
I am getting URISyntaxException Illegal character in query at index
I think this is because of characters such as | in my URL.
java.lang.IllegalArgumentException: Illegal character in query at index 171: https://evolven.wlb4.apac.nsroot.net:8441/enlight.server/html/scripts/api/assets.jsp?action=table&all=true&envId=92738683&globalCrit=Host%20where%20name:sdcgcgtiblb20pv%20|%20Certificates%20where%20Until%3E1d%20AND%20Until%3C31d%20&%20EvolvenSessionKey=ebc864ab09b8fc7be406c62731b25435ec3155be&json=true
at java.net.URI.create(URI.java:852)
at org.apache.http.client.methods.HttpPost.<init>(HttpPost.java:73)