## php.java.servlet
Class PhpJavaServlet

    java.lang.Object
      javax.servlet.GenericServlet
          javax.servlet.http.HttpServlet
              php.java.servlet.CGIServlet
                  php.java.servlet.FastCGIServlet
                      php.java.servlet.PhpJavaServlet

All Implemented Interfaces:
  java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

    public class PhpJavaServlet

extends FastCGIServlet

Handles requests from PHP clients. When apache or IIS are not available, this servlet can start php as a CGI sub-process.
However, it is recommended to install php as an Apache module and to share the servlet engine's `webapps` directory with apache's `htdocs` directory. This is default since RH Fedora 4.
For frameworks, such as Java Server Faces, it is recommended to forward requests to the backend as follows:
`<?php
function toString() {"return "hello java world!";}
java_context()->call(java_closure()) ||header("Location: hello.jsp");
?>
`
This allows the framework (jsf, struts, ...) to call php procedures as follows:
`PhpScriptEngine e = new PhpScriptEngine();
e.eval(new URLReader(new URL("http://.../hello.php")));
out.println(((Invocable)e).invoke("toString", new Object[]{}));
e.release();
`
An alternative would be to install `mod_jk` to "JkMount" the java "webapps" document root into the "htdocs" document root of the HTTP server and to configure it so that it automatically forwards all .jsp and servlet requests to the servlet engine.

See Also:
  Serialized Form

Field Summary
`static int` `CGI_CHANNEL` The CGI default port

Fields inherited from class php.java.servlet.FastCGIServlet
`FCGI_CHANNEL`

Constructor Summary
`PhpJavaServlet()`

Method Summary
`void` `destroy()` Called by the servlet container to indicate to a servlet that the servlet is being taken out of service.
`void` `init(javax.servlet.ServletConfig config)` Sets instance variables.

Methods inherited from class php.java.servlet.CGIServlet
`getLocalPort`

Methods inherited from class javax.servlet.http.HttpServlet
`service`

Methods inherited from class javax.servlet.GenericServlet
`getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### CGI_CHANNEL

    public static final int CGI_CHANNEL

  The CGI default port

  See Also:
    Constant Field Values

Constructor Detail

### PhpJavaServlet

    public PhpJavaServlet()

Method Detail

### init

    public void init(javax.servlet.ServletConfig config)
              throws javax.servlet.ServletException

  Description copied from class: `CGIServlet`
  Sets instance variables.

  Modified from Craig R. McClanahan's InvokerServlet

  Specified by:
    `init` in interface `javax.servlet.Servlet`
  Overrides:
    `init` in class `FastCGIServlet`
  Parameters:
    `config` - a `ServletConfig` object containing the servlet's configuration and initialization parameters
  Throws:
    `javax.servlet.ServletException` - if an exception has occurred that interferes with the servlet's normal operation
  See Also:
    `UnavailableException`

### destroy

    public void destroy()

  Description copied from class: `javax.servlet.GenericServlet`
  Called by the servlet container to indicate to a servlet that the servlet is being taken out of service. See `Servlet.destroy()`.

  Specified by:
    `destroy` in interface `javax.servlet.Servlet`
  Overrides:
    `destroy` in class `FastCGIServlet`