I have a php script which is executed over a URL. (e.g. www.something.com/myscript?param=xy)
When this script is executed in a browser it gives a coded result, a neg
If your J2EE app is deployed on the same server the PHP script is on, you can also execute it directly through as an independent process like this:
public String execPHP(String scriptName, String param) {
try {
String line;
StringBuilder output = new StringBuilder();
Process p = Runtime.getRuntime().exec("php " + scriptName + " " + param);
BufferedReader input =
new BufferedReader
(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
output.append(line);
}
input.close();
}
catch (Exception err) {
err.printStackTrace();
}
return output.toString();
}
You will pay the overhead of creating and executing a process, but you won't be creating a network connection every time you need to execute the script. I think that depending on the size of your output, one will perform better than the other.