I have a PHP URL that inserts a record into a CRM system. I need in my servlet to execute this URL - as if I was redirecting to the page (I don't really want to redirect to the page)
I have code that connects to the URL and reads the content of the page but what I want is just to "Execute" the URL .
What am I missing?
Thanks.
URL myURL = new URL("http://mydomain.com/test.jsp?myparam=bb");
URLConnection myURLConnection = myURL.openConnection();
myURLConnection.connect();
BufferedReader in = new BufferedReader(new
InputStreamReader(myURLConnection.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine);
}
in.close();
You can try JSoup
String url = "http://mydomain.com/test.jsp?myparam=bb"";
Document doc = null;
try {
doc = Jsoup.connect(url).get();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
You could use the commons net library. Here's the home tutorial: http://hc.apache.org/httpclient-3.x/tutorial.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.