Results 1 to 6 of 6
- 05-24-2012, 02:59 AM #1
Senior Member
- Join Date
- Apr 2012
- Posts
- 127
- Rep Power
- 0
URLConnection -- does it count as a "click"?
Hello, i'm working on a program that will fetch a webpage from my company's site and download its content. I am having a hard time figuring out if URLConnection object used with the openConnection() method actually counts as a "hit" or "Click" or not? I would like it to count as this is an intranet site and it would be great to be able to monitor how many times employees have downloaded the page...
this is the code i have so far.
thanks for any input.Java Code:public static void httpConn(String destUrl, String searchTerm) throws IOException, InterruptedException { strS = ""; try { URL url = new URL(destUrl + searchTerm); Thread.sleep(500); URLConnection conn = url.openConnection(); conn.setRequestProperty("User-Agent", "Mozilla/5.0 (X11; U; Linux x86_64; en-GB; rv:1.8.1.6) Gecko/20070723 BbeWeb/2.0.0.6 (Debian-2.0.0.6-0etch1)"); BufferedReader in = new BufferedReader( new InputStreamReader(conn.getInputStream())); Thread.sleep(500); System.out.println("Results returned... \n"); while ((str = in.readLine()) != null) { strS += "\n" + str; //System.out.println(str); str = ""; } in.close(); } catch (MalformedURLException e) { System.err.println("Error: " + e.getMessage()); } catch (IOException e) { System.err.println("Error: " + e.getMessage()); } httpConnRun = true; }
- 05-24-2012, 05:52 AM #2
Re: URLConnection -- does it count as a "click"?
Moved from New to Java
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 05-24-2012, 09:30 AM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Re: URLConnection -- does it count as a "click"?
Your server (the one with the page you are requesting via the URLConnection) does not really know where that connection is coming from, unless it is only counting certain browsers (unlikely), so any request should be registered.
Besides, it's an intranet so you should be able to do a simple check.Please do not ask for code as refusal often offends.
- 05-24-2012, 04:44 PM #4
Senior Member
- Join Date
- Apr 2012
- Posts
- 127
- Rep Power
- 0
Re: URLConnection -- does it count as a "click"?
ok thanks. so just so i make sure i understand correctly... web servers in general cannot tell the difference between a web browser user mouse "click" on a link and a URLConnection fetching the data from the page, because they both accomplish the same thing - a GET request to the server to fetch the page requested, then the server returns that page as if a user clicked on it? I"m dont know a whole lot about how browsers work so please bear with me.
Also, I dont have any feasible way to test on the intranet on our site as its hosted at another location and lots of internal traffic hits it (so i cant run my program, check the stats, run again, etc).
thanks again, just trying to make sure i can rely on this method to accomplish the expected result. thanks!
- 05-26-2012, 10:26 PM #5
Re: URLConnection -- does it count as a "click"?
Can you add a parameter to the URL the server could use to detect your testing?
If you don't understand my response, don't ignore it, ask a question.
- 05-29-2012, 04:35 PM #6
Senior Member
- Join Date
- Apr 2012
- Posts
- 127
- Rep Power
- 0
Similar Threads
-
Is there a way to play the video until I click the "start "button?
By aprilcomingsoon in forum XMLReplies: 0Last Post: 06-07-2010, 06:23 PM -
output "left click"/enter command?
By Arsenic in forum New To JavaReplies: 2Last Post: 06-04-2009, 05:01 AM -
Content type for MS files "content/unknown" with URLConnection
By serjant in forum NetworkingReplies: 2Last Post: 05-30-2009, 10:42 AM -
Count lines cointaining "word" in input file
By gwithey in forum New To JavaReplies: 5Last Post: 04-02-2009, 05:23 AM -
the dollar sign "$", prints like any other normal char in java like "a" or "*" ?
By lse123 in forum New To JavaReplies: 1Last Post: 10-20-2008, 07:35 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks