### 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`

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. Since Fedora Linux version 4 the tomcat `webapps` directory and the Apache `htdocs` directory are shared by default (via a symlink).
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("/hello.php")));
out.println(((Invocable)e).call("java_get_server_name", 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`

## Method Summary

`void`

`destroy()`

`void`

`init(javax.servlet.ServletConfig config)`

### Methods inherited from class php.java.servlet.FastCGIServlet

`destroy`, `fcgiIsAvailable`, `init`

### Methods inherited from class php.java.servlet.CGIServlet

`init`

### Methods inherited from class javax.servlet.http.HttpServlet

`service`

### Methods inherited from class javax.servlet.GenericServlet

`destroy`, `getInitParameter`, `getInitParameterNames`, `getServletConfig`, `getServletContext`, `getServletInfo`, `getServletName`, `init`, `init`, `log`, `log`, `service`

### Methods inherited from class java.lang.Object

`equals`, `getClass`, `hashCode`, `notify`, `notifyAll`, `toString`, `wait`, `wait`, `wait`

## Field Details

### CGI_CHANNEL

    public static final int CGI_CHANNEL

> The CGI default port

> Field Value:
>   9567

## Method Details

### destroy

    public void destroy()

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

### init

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

> Specified by:
>   init in interface javax.servlet.Servlet
> Overrides:
>   init in interface FastCGIServlet