Passing data from CGI to Java and back

Discussion in 'Web Design & Coding' started by wessleym, Apr 11, 2006.

  1. wessleym

    wessleym OSNN Addict

    Messages:
    99
    For a class, I have to pass data from a CGI (written in Perl) script to a Java program. This is easy enough, but I need to make the Java program return the data it finds to the CGI script. Can someone tell me how to do that?
     
  2. Geffy

    Geffy Moderator Folding Team

    Messages:
    7,805
    Location:
    United Kingdom
    depends on how you are passing the data to the java program. If you are running it as a command line application then you can just print the output from the java program to the standard output device and use backticks (`) to call the java program

    Code:
    perlvar = `java MyJavaApp param1 param2`
    thats how I would go about it, its not the most safe and secure way mind, so make sure you do a damn good job of cleaning any parameters you are passing to the java program so that you dont get random code executed alongside your call to the java program
     
  3. wessleym

    wessleym OSNN Addict

    Messages:
    99
    Geffy, thanks so much! I thought about doing that but never thought it would work. It seemed too simple. Thanks again!