Hi,

I'm just a beginner of PHP. At the moment, I'm thinking of switching JSP to PHP.

In PHP, how can i call a servlet? Is there any example which i can dowload from internet?

Thank you so much for the appreciated!

Alex

    20 days later

    alex,

    There is a standard PHP extension in the PHP distribution called sapi/servlet (see <php4>/sapi/servlet/README). It allows your PHP engine to run inside your servlet capable web server (e.g. Tomcat) as a servlet and also allows you to reference/instantiate any Java class including other Servlets (see <php4>ext/java/README). If you're running on the Win32 platform you can simply download the zipped binaries of PHP4 and the Servlet feature from either www.php.net or www.php4win.de. On other platforms you simply need to rebuild PHP specifying --with-servlet --with-java on the configure statement and then follow the rest of the instructions in the sapi/servlet/README. There are various samples provided in that directory as well (e.g. sapi/servlet/cookies.php).

    Note that this moves your PHP processing from your HTTP server to your Java server (which is hopefully more robust and capable). There are probably other ways you can accomplish this but this will be the best performer by far (JVM caching and management is done by the Java web server instead of by PHP, etc.).

    Alex

      Write a Reply...