开发者

Is it possible to use JSP and PHP at the same time?

1 function is written in Java while the API of another function is written in PHP. So, is it possible to use JSP and PHP at the sam开发者_JS百科e time?


I would say that you could call (from your Java code) a different process to execute the PHP script, and then use the output of that PHP script in your Java code -- but that's certainly not optimal, and will not allow you to call only one PHP function.

Using both Java and PHP code in the same application seems a bit complicated, and I've never seen this done -- nor used in any way ; so, I would probably rewrite the PHP code to Java (or the Java code to PHP), so the whole application is written in only one of those two languages.


I've never tried it, but maybe a possibility would be using Quercus -- see, for instance : java and php integration

It seems to be able to run Drupal (a popular PHP CMS ; which means quite a lot of functionnalities) : Running Drupal 6.2 on Resin 3.1.6 ; so I'd say it might be worth a look...


When you say JSP and PHP, it is a mixed bag. Java and PHP as two languages, OK. But JSP and mod_PHP as two server interfaces, NO.

To run a mod_PHP program you must setup certain (many) server variables which PHP will use. The same to run a Jsp program, the server environment must be established.

But to run a mod_PHP program and call (in some fashion) a Java program, as @Pascal wrote, sure, but the linkage is inefficient. And the same the other way, a JSP program can launch a PHP (CLI) program too.


There is Java integration available in PHP, but that's for accessing Java classes in PHP and probably won't let you use JSP without a lot of hacking.


You can do it if you are App servers like Resin which support PHP or using experimental PHP / Java Integration. Note that running PHP on Resin may not support all extensions for a given application but I have ran Wordpress on Resin and it's neat.


In general no. There is, however, a PHP implementation written in Java which will most likely allow you to do what you need which can run in most web containers.

Have a look at Quercus from Caucho. Here is the tutorial: http://quercus.caucho.com/quercus-3.1/examples/quercus.xtp


You should consider the following design.

  1. Your PHP pages run on Apache http with the mod.
  2. Your JSP pages run on Apache tomcat.
  3. Run a memory based rdbms.

All three is run on the same system.

Inter PHP-JSP communication would be conducted on two ends:

  1. the frontend JSP and PHP web services
  2. and the backend memory-based rdbms.

Disclaimer: I have never even seen any PHP code in all my 30 years' programming life. Perhaps, once, actually. Therefore, I have faint idea how difficult it might be to have PHP serve web services.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜