使用drupal调用java代码
我可以在Drupal中调用java代码吗?就像当我单击按钮时,我需要发送一些变量作为参数并调用返回一些值的 java 程序。我想使用这些数据作为视图中的过滤器。
有可能吗?
谢谢, 拉姆亚
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,这是可能的。除了在服务器上运行应用程序或“直接”从 PHP 执行代码之外:如果“Java 代码”实际上是 JSP 脚本,您可以像任何其他远程页面一样调用它,通过例如传递参数。得到。
例如,处理来自调用 URL 的响应: http://example.com/script.jsp?my_variable=my_value
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 曾经有一个 Java 扩展来使用 PHP 中的 Java 类。但这已从 PHP 5+ 中删除。 Zend Server 出于相同目的提供了 Java Bridge 组件。 Quercus,Java 中的 PHP 实现,还提供了 集成层
您还可以使用提供计算结果的 Java 服务器在 Java 代码和 PHP 之间构建自己的桥梁到 PHP 客户端。许多技术(XML-RPC、SOAP、REST、协议缓冲区< /a> 等)可用于构建此类解决方案,这实际上取决于您的偏好。
最后,始终可以选择将小型 Java 应用程序作为 系统程序。
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.
是的,这是可能的,但不建议这样做。
您可以使用 exec()、system() 和 passthru() 等 php 函数来完成此操作。
许多托管提供商通常不支持它们,因为它们被认为是危险的,因为它们只是在服务器上执行程序。
在通过这些函数之一传递输入之前,请务必先解析输入。
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.