Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2006

Tip: Looking for answers? Try searching our database.

Multiple serverside processes - Java PHP?

Thread view: 
rexdtripod@hotmail.com - 17 Nov 2006 19:34 GMT
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.
Daniel Pitts - 18 Nov 2006 18:00 GMT
> I currently have two successful serverside processes that need to be
> married together.  One is a servlet that performs complex calculations.
[quoted text clipped - 16 lines]
>
> 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
Simon Brooke - 18 Nov 2006 18:01 GMT
> I currently have two successful serverside processes that need to be
> married together.  One is a servlet that performs complex calculations.
[quoted text clipped - 3 lines]
> 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.

Signature

simon@jasmine.org.uk (Simon Brooke) http://www.jasmine.org.uk/~simon/

       ;; L'etat c'est moi                     -- Louis XVI
       ;; I... we... the Government            -- Tony Blair



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.