Original Post
So I'm playing with a system that needs to be implemented using a web server (Apache, or others; it doesn't really matter which), PHP, and Java. However, I'm unsure of just how PHP and Java can actually work together. It seems to me that Java's servlets attempt to accomplish many of the same tasks that PHP does. I want to use Java for the backend of the server and PHP for the frontend to generate pages that users see. I've read about experimental extensions for PHP to allow it to directly access Java classes, but I don't want to go that direction. My question is, if I implement an HttpServlet and write out PHP as a response, is there a way to then have that PHP parsed by the web server as usual and sent to the client as pure HTML? Does this happen automatically? For example: Note that I left out details for brevity. If I sent out a response with PHP in it, would the web server be able to catch it, run it through PHP, and send pure HTML to clients? PHP is really just being used to create dynamically generated pages and provide tools like a calendar. For that matter, does anyone know how to generate a request in PHP and forward it to a servlet? Any insight is appreciated. Thanks! P.S. I know there are a lot of questions in here, so links to sites with some answers are also appreciated. :-)
public class SomeServlet implements HttpServlet {
...
public void doGet(HttpServletRequest request, HttpServletResponse response) ... {
PrintWriter out = response.getWriter();
...
out.println("<?php phpinfo() ?>");
...
}
...
}