-1

I have a string that includes a link that needs to be opened every time a certain criteria is met to collect data on my webserver.

E.G.

String url = mywebsite.com/counter.php
    if(addCounter){
openLink(url);//made-up method
addCounter = false;
}

But I do not want this page to be opened in any kind of browser. It just needs to be visited and that's it. Every visit to counter.php increases the count of the integer inside the PHP by one. So basically, all it ever needs to do is inquire the page.

How can I do this?

joe dacoolguy
  • 309
  • 2
  • 8
  • 18

1 Answers1

0

Well it depends on what you have inside openLink. Looks like currently you are opening it in browser. The simplest way of just accessing it would be pure Java.

 URL u = new URL(url);
 HttpURLConnection http = (HttpURLConnection)u.openConnection();
 http.connect();

This way you make a request yo your site. If you wish to see the output by the server, you can using http.getInputStream.

Jatin
  • 31,116
  • 15
  • 98
  • 163