开发者

Call java code using drupal

Can I call开发者_开发技巧 java code in Drupal? Like when I click a button I need to send some variables as arguments and call a java program which returns some value. I want to use this data to as filters in views.

Is it even possible?

Thanks, Ramya


Yes, it is possible. In addition to running application on the server or executing code 'directly' from the PHP: if the 'Java code' is actually JSP script, you can call it as any other remote page, passing arguments through eg. GET.

For example processing response from invoked URL: http://example.com/script.jsp?my_variable=my_value


PHP 4 used to have a Java extension to use Java classes from PHP. But this has been removed from PHP 5+. The Zend Server provides a Java Bridge component for the same purpose. Quercus, a PHP implementation in Java, also provide an integration layer

You can also build you own bridge between your Java code and PHP with a Java server serving computation results to a PHP client. Many technologies (XML-RPC, SOAP, REST, Protocol Buffer, etc.) are available to build such solution and it really depends on your preferences.

Finally there is always the option to execute a small Java application as an system program.


Yes this is possible but it isn't recommended. You can do this using php functions like exec(), system(), and passthru().

These are often not supported by many hosting providers as they are considered dangerous because of the fact they just execute programs on the server. Be sure to parse input well before you throw them trough one of these functions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜