| Author |
Execute php from Java
|
Melanie Walsh
Greenhorn
Joined: Dec 14, 2004
Posts: 20
|
|
Hi I am still trying to execute a php script from within my java class. I have tried the following code to pass a var and nothing happens. Can anybody help? This is for my final year project, the php scrpit retrieves data form internet based on info entered in the java gui, trouble is i cant get the php script to run, i can open and read using URL object but not run, thius is the trial code im using:- String program = "Eastenders"; public static void main(String[] args) throws Exception { try{ URL localScript = new URL("http://localhost/BBC2Test3.php/?program"); URLConnection phpConnection = localScript.openConnection(); } catch (MalformedURLException e) { System.out.println("URL Failed"); // new URL() failed } catch (IOException e) { // openConnection() failed System.out.println("Open Connection Failed"); } }
|
 |
Greg T Robertson
Ranch Hand
Joined: Nov 18, 2003
Posts: 91
|
|
And if you execute that same script from within a browser what resutls do you get? It's probably being fed by a form from somewhere - is it a post or get? You say it doesn't execute - but are you certain it's not executing - or are you just seeing no results? Any exceptions of any type at all?
|
 |
Tim McGuire
Ranch Hand
Joined: Apr 30, 2003
Posts: 819
|
|
without seeing all the code, I will guess that your URL string needs to look like this: instead of this:
|
 |
 |
|
|
subject: Execute php from Java
|
|
|