Java Java output to script call

My goal is to run CGI on the apache web server. My CGI is written in Java. I use a batch file (later may be a perl script) that runs java CGI, which does the whole business.

The batch file runs and runs Java CGI. The java program itself works. BUT nothing is sent back to the browser from my java code. I am making a simple System.out.println to send stuff to the browser. I use this as a link

My batch file

    echo Content-Type: text/html
    echo.
    echo ^<html^>^<head^>^</head^>^<body^>
    echo Hello world!!!
    java -cp My.jar MyClass
    echo ^</body^>^</html^>

My java file

    new File("C:\\wamp\\www\\cgi-bin\\" + new Date().getTime()).mkdir();
    System.out.println("<b>Hello world from Java</b>");

. , ( ..) 2 3 , . . , , JMS, ajax .., ...

0
1

, ,
  java -cp My.jar MyClass , , , , for /f...

@echo off
  rem  This works in Wampserver Apache cgi-bin...
  rem     http://localhost/cgi-bin/testbat.bat
echo Content-Type: text/html
echo.
echo ^<html^>^<head^>^</head^>^<body^>
echo ^<H1^>Hello world!!!^</H1^>
echo ^<PRE^>
FOR /F "usebackq delims==" %%i IN (`dir`) do echo %%i
echo ^</PRE^>
echo ^</body^>^</html^>

, , :)

0

Source: https://habr.com/ru/post/1730712/


All Articles