I have a jsp + servlet web app. I have to problem when I need to bridge to external technologies:
From the user registration page I would like to call a PHP script to send a message to the user when the process is completed. Note that the script is already available and I need to pass the phone number as a string. Is there a quick solution from the JSP page? I don't need to control the flow or catch any error, just call the sendMessage(String phoneNumber) script.
I guess a bit more complex, I don't know if a php-bridge is required. Same as above but I need to catch a return value from the PHP script. The validateCode(String phoneNumber) is pretty simple. It may return a integer code (from 1 to 5) and I would like from a servlet - or eventually a JSP - to handle the code and do some logic.
There's really no such thing as a Java/PHP bridge, but these technologies are malluable enough that connecting them is pretty simple.
For example, one way to connect them in the context of a web environment is to have them make http calls to each other. You can restrict external people from doing this by having the php/jsp check to make sure the person executing the page has a local ip address. The advantages are that the programs never look at the internal structure of each other and therefore you can swap in JSP-to-JSP communication or PHP-to-PHP communication if you get rid of one of the technologies.
The other option is to have them drop to command line. For example, calling Runtime.exec() in java to run a php script. This is usually very fast but it might require a tighter coupling than the previous method in that your php calls may be extremely machine sensitive.
I will give both the options a try and see which one suits better my web app. Looks like I can call (quite) easily the PHP script but I won't be able to collect what I have back from the call. Is my assumption correct?