Search code examples
javaphptomcatservletsapache-fop

How to talk to Tomcat server from a PHP application


I am developing a new report engine for my company, our main web application is writing by PHP 5 and running on an Apache server. The new report server which I designed to use Apache FOP 1.0 ruing on Tomcat7,so far I created My own XSLT stylesheets and I can manage to generate a PDF report from the URL and let it display in my web browser.My goal on this project is to generate dynamic report from xml file which export from the PHP application.

Could anyone explain to me the logic behind How I can give those two talk to each others. I understand I could POST the XML and XSLT as string to the report server and POST it back the result I want(like PDF).

I know this will need Java involved,and as a PHP dev. I really don't have much background about Java,if you could show me some examples or links, it would be much appreciate.

I am using Saxon-B with Fop 1.0 on Tomcat 7 for the report server.

if you need more info from me,please also leave a comment. I will add it soon.

Thanks


Solution

  • There are two things your going to need to study.

    1. http://www.w3schools.com/php/php_ajax_intro.asp This is a tutorial on using the XHR object from php. You should go through that. Also, if you aren't familiar with the XHR object, I would read this as well: http://www.w3schools.com/XML/xml_http.asp
    2. You're going to have to create a servlet capable of responding to these requests. There are various tutorials on how to create a servlet.

    Here is a link to a youtube video I fall back on when I forget how to do servlets: http://www.youtube.com/watch?v=EOkN5IPoJVs

    In the video, he just uses straight up javascript; so you're php code is going to be doing what the javascript did in the video (item 1 on my list).

    The video uses an older version of eclipse (I think ganymede), but it is pretty close to the same process in the newest version of eclipse.

    Just to be blunt, this isn't something you're going to be able to figure out and make work properly. You've probably got at least a day to a weeks worth of learning here depending on your experience and aptitude; and this will only get you something basic. The servlet you make won't be secure, it won't have user authentication...my point is don't take anything for granted.