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

前端 未结 6 1627
小鲜肉
小鲜肉 2021-01-07 00:51

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 same time?

相关标签:
6条回答
  • 2021-01-07 00:52

    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 讨论(0)
  • 2021-01-07 00:54

    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...

    0 讨论(0)
  • 2021-01-07 01:03

    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.

    0 讨论(0)
  • 2021-01-07 01:13

    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.

    0 讨论(0)
  • 2021-01-07 01:15

    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

    0 讨论(0)
  • 2021-01-07 01:16

    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.

    0 讨论(0)
提交回复
热议问题