I want to use php in place of jsp/servlets for my web app whose service layer and database layer has been written in java. It is possible to do so? If yes, can a web hosting server run both of them simultaneously?
3 Answers
Take a look at Palava. Our main goal of this framework is exactly want you want:
- PHP Scripts instead of JSP/Servlets, but
- a reliable and fast Java backend
Comments
You can take a look at http://php-java-bridge.sourceforge.net/pjb/FAQ.html Or, as mentioned before use mod_proxy. Yet another way would be to setup java locally and have php call some sort of REST or SOAP java api to get the data and then display it.
Comments
The easiest way is probably to have one php webserver and one servlet container such as tomcat. You can configure tomcat to run on a different port such as 8080 and use apaches mod_proxy to make the servlet container available on port 80.
Here's what my configuration looks like:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName mydomain.com
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
There's also a PHP implementation in Java called Quercus. I haven't tried it, but it might be worth checking out.
The last time it tried the php-java-bridge, it seemed rather slow. However, that was back in 2007, so things might have changed.