Multiple serverside processes - Java PHP?

R

rexdtripod

I currently have two successful serverside processes that need to be
married together. One is a servlet that performs complex calculations.
Another is a PHP script that distills user input into an xml formatted
email attachment and sends.

Is it possible to link these two in some way without rewriting one in
the other language? I need one user submit to trigger it all.

Rewriting the calculation stuff in PHP would not be possible. Far too
complex. I could move the email xml attachment functionality into the
servlet. I'd have to rewrite using javamail.

Amazing how much more code the javamail version would be and apparently
the javamail attachment thing might not be reliable across all mail
clients (been seeing threads claiming dropped or corrupted attachments
in some clients, http://tinyurl.com/y72phk).

Any other options?

Thanks in advance.
 
D

Daniel Pitts

I currently have two successful serverside processes that need to be
married together. One is a servlet that performs complex calculations.
Another is a PHP script that distills user input into an xml formatted
email attachment and sends.

Is it possible to link these two in some way without rewriting one in
the other language? I need one user submit to trigger it all.

Rewriting the calculation stuff in PHP would not be possible. Far too
complex. I could move the email xml attachment functionality into the
servlet. I'd have to rewrite using javamail.

Amazing how much more code the javamail version would be and apparently
the javamail attachment thing might not be reliable across all mail
clients (been seeing threads claiming dropped or corrupted attachments
in some clients, http://tinyurl.com/y72phk).

Any other options?

Thanks in advance.

Generally, Java servlets live in a servlet container, where PHP pages
are executed through CGI. It completely depends on the platform you're
using on how to combine the two. I believe resin can do both without
too much work, as it supports J2EE and PHP
 
S

Simon Brooke

in message <[email protected]>,
I currently have two successful serverside processes that need to be
married together. One is a servlet that performs complex calculations.
Another is a PHP script that distills user input into an xml formatted
email attachment and sends.

Is it possible to link these two in some way without rewriting one in
the other language? I need one user submit to trigger it all.

Easy. Do a client-side redirect from one to the other. You can pass any
arguments you like in the redirect URL, although this isn't very secure as
they will go over the network in clear twice. Or you can create a uniquely
named temporary file on the server, and pass it's name as an argument in
the redirect URL.

HttpServletResponse res =
(HttpServletResponse) context.get( RESPONSEMAGICTOKEN );
HttpServletRequest req =
(HttpServletRequest) context.get( REQUESTMAGICTOKEN );
URL desturl = null;

if ( req != null ) // it *shouldn't* be..
{
// normalise the URL if possible (should be)
URL here = new URL( req.getRequestURL( ).toString( ) );

desturl = new URL( here, deststring );
}
else
{
desturl = new URL( deststring );
}

// convert it back into a string
deststring = desturl.toString( );

res.setStatus( HttpServletResponse.SC_MOVED_TEMPORARILY );
res.setHeader( "Location", deststring );

You can do the equivalent in PHP but seeing it's ten years since I built
anything significant in PHP I'll leave that to others.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top