I'd like to dynamically generate a PHP file from a servlet, then have Apache execute it. Is this possible? Setting the Content-type does not seem to help.

Alex Chaffee

[I am working with Apache 2 with Tomcat 4.1. I am integrating some system that was built with servlets, with some PHP project. What I need to do is generate PHP files from servlets. Problem is that after generating the files , Apache does not parse it as PHP files , which is not good :-). I;ve tryed to change the pageContent of HTTPResponse to "text/plain" - Nope. "text/html" - presents the
files as HTML without the PHP part , it simpoy ignores it. I've even tryed setting it to "application/x-httpd-php" , in this case after clicking on link it saves me the file on my computer (Apache does not understand the file type. ]


You need to write the PHP files to your server's disk drive, in the htdocs directory. Then send a browser redirect to the URL corresponding to the file you just wrote.

The client will then ask the server for that file; Apache will notice the PHP file on its disk and execute the PHP interpreter on it.

There's no way to get Apache to invoke the PHP interpreter directly on pages output by Tomcat. It happens too late in the dispatching game.