Hello,
I have a PHP page and a 'Hello World' servlet. Here is the content of
both:
PHP code:
<?
print "I am now calling the servlet...<p>";
exec( "http://ip_address:8080/HelloWorld" );
?>
Java code:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Hello World!");
}
}
The servlet works fine by itself (running on Apache server w/ Tomcat
4.1, accessed by the url: http://ip_address:8080/HelloWorld). However,
I cannot seem to call the servlet from the PHP code. I.e., what I want
is for the output of the PHP to be:
I am now calling the servlet...
Hello World!
I am using PHP 4.3.1 and I have the Java extension enabled, although
I would rather not use them because everything that I've read about
this extension suggests that it's very unstable and still
experimental. I'd prefer to use an exec() statement or something else,
but nothing that I've tried so far works.
I've also tried rewriting the servlet as a stand-alone Java
application (with a main, etc.), and calling...
exec( "java D:/path/to/java/app/HelloWorld" )
and also...
`java "D:/path/to/java/app/HelloWorld"`
but nothing seems to work. The idea situation would be to call a
servlet rather than a Java app, but I would consider either a solution
to my problem.
Any help would be great.
Thanks,
Darren |