integrate two sites' content at runtime
===

Planning to use php-based CMS to manage content of several sites.

But 2 of them are based on Tomcat + JSP, not php - i can't integrate them directly into CMS, so I need to "inject" them from PHP internal. JSP site implemets several web forms, use ajax and live theirs own life, and I need to wrap it with CMS to manage banners, news, articles and other content, placed around jsp form.

I've wrote an proxy.php that took all requests grabs (with file_get_contents(...)) external sites's HTML, parse it with DOMDocument to add prefix to it's resources (was /js/js.js, became /external_site/js/jw.js and etc.), render html directly with "echo" and configured nginx to get static content based on /external_site/.

But the problem is that external site's forms have buttons and links, and all posts should be handled by servlets.

This is not an ideal solution from all points and all traffic should be passed throught CMS.

Main question is there some frameworks or best practice form making such includings ?