Results 1 to 7 of 7
- 12-14-2010, 10:23 PM #1
Member
- Join Date
- Nov 2010
- Posts
- 12
- Rep Power
- 0
HttpConnection not using PHP script?
I am making a connection to my server (hosted on my machine via an apache framework) from a java program using the following method:
(Example taken from Java connect to website - CodingForums.com).Java Code:try { URL ourURL = new URL("http://www.codingforums.com/external.php?type=RSS2"); //Coding Forums RSS Feed HttpURLConnection huc = (HttpURLConnection)ourURL.openConnection(); huc.setRequestMethod("GET"); huc.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; JVM)"); huc.setRequestProperty("Pragma", "no-cache"); huc.connect(); BufferedReader reader = new BufferedReader(new InputStreamReader(huc.getInputStream())); String line = null; while ((line = reader.readLine()) != null) { // Either do your parsing here, or append it to a StringBuffer for later use } catch(IOException ioe) { ioe.printStackTrace(); } catch(Exception e) { System.err.println("General Exception " + e); e.printStackTrace(); }
When I visit my webpage, it appears that a connection is made (in that no exceptions are thrown), but the php script running on my server does not seem to be executed. (It would incremement a counter in the SQL database, also hosted on my machine).
Why does the php script not get executed?
Thanks for any input.
- 12-15-2010, 03:43 PM #2
Member
- Join Date
- Dec 2010
- Posts
- 15
- Rep Power
- 0
Why didn't you do with response from server?Java Code:while ((line = reader.readLine()) != null) { // Either do your parsing here, or append it to a StringBuffer for later use }
- 12-15-2010, 06:33 PM #3
Member
- Join Date
- Nov 2010
- Posts
- 12
- Rep Power
- 0
Thanks for the reply.
Will reading stuff in cause execution of the PHP script? I thought the PHP script was executed on the server end as soon as the client connects to the server...
- 12-15-2010, 06:48 PM #4
Member
- Join Date
- Dec 2010
- Posts
- 15
- Rep Power
- 0
Would you like to do?
- 12-15-2010, 07:09 PM #5
Member
- Join Date
- Nov 2010
- Posts
- 12
- Rep Power
- 0
My goal here is to get the php script on my site to execute. This happens whenever a person using a browser connects to my site. I want to reproduce this using a program to connect to my site instead of a browser.
- 12-15-2010, 07:26 PM #6
Member
- Join Date
- Nov 2010
- Posts
- 12
- Rep Power
- 0
It appears that what was needed was in fact to start reading from the page. Not sure why this has to happen, but it looks like it is getting the desired result. Thanks for the replies.
- 12-15-2010, 08:17 PM #7
Member
- Join Date
- Nov 2010
- Posts
- 12
- Rep Power
- 0
I do have a followup to this question - Does opening up tons of connections to different URL's really quickly look a lot like a DOS attack?
I am writing a web crawler that visits each link it picks up on a given webpage, and continues to do this recursively. I don't want to risk my ISP or the given website thinking this is a DOS attempt.
Thanks.
Similar Threads
-
Script not working with IE7
By sfphoto in forum New To JavaReplies: 1Last Post: 12-13-2010, 05:08 PM -
Jquery pop out script
By fOmey in forum New To JavaReplies: 1Last Post: 12-03-2010, 02:13 AM -
How to set TextArea after getting it's value from CGI script
By Basit781 in forum CLDC and MIDPReplies: 1Last Post: 05-25-2010, 09:53 AM -
HttpConnection problem
By girija in forum NetworkingReplies: 2Last Post: 04-04-2008, 07:13 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks