Invoking a PHP method from Java [closed]

I need to invoke a PHP method from java. Can I do that with request dispatcher?


Here is a handy way to invoke a PHP method from within a Java application.

Runtime.getRuntime().exec("php <your script name>");

You'll need to make a separate request as though it was to an external site, but that will essentially be a full web request. There is no way to call a single PHP function from within Java unless you've got a PHP interpreter in your JVM, which seems highly unlikely.

You probably want to write the PHP side like you would write for an AJAX interface (using JSON or some loosely defined XML) or a SOAP interface.