## php.java.servlet
Class ServletContextFactory

    java.lang.Object
      php.java.bridge.http.SimpleContextFactory
          php.java.servlet.ServletContextFactory

All Implemented Interfaces:
  IContextFactory, IContextFactoryVisitor

Direct Known Subclasses:
  PhpFacesScriptContextFactory

    public class ServletContextFactory

extends SimpleContextFactory

Create session contexts for servlets.

In addition to the standard ContextFactory this manager keeps a reference to the HttpServletRequest.

See Also:
  `ContextFactory`, `ContextServer`

Method Summary
`static ServletContextFactory` `addNew(javax.servlet.ServletContext kontext, javax.servlet.http.HttpServletRequest proxy, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)` Create and add a new ContextFactory.
`java.lang.Object` `createContext()` Return an emulated JSR223 context.
`void` `destroy()` Removes the context factory from the classloader's list of context factories and destroys its content.
`ISession` `getSession(java.lang.String name, boolean clientIsNew, int timeout)`
`void` `setSession(javax.servlet.http.HttpServletRequest req)` Set the HttpServletRequest for session sharing.
`java.lang.String` `toString()`

Methods inherited from class php.java.bridge.http.SimpleContextFactory
`getBridge, getContext, getId, recycle, recycle, remove, setBridge, setContext, visit, waitFor`

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

Method Detail

### setSession

    public void setSession(javax.servlet.http.HttpServletRequest req)

  Set the HttpServletRequest for session sharing.

  Parameters:
    `req` - The HttpServletRequest

### getSession

    public ISession getSession(java.lang.String name,
                               boolean clientIsNew,
                               int timeout)

  Specified by:
    `getSession` in interface `IContextFactory`
  Overrides:
    `getSession` in class `SimpleContextFactory`
  Parameters:
    `name` - The session name. If name is null, the name PHPSESSION will be used.
    `clientIsNew` - true if the client wants a new session
    `timeout` - timeout in seconds. If 0 the session does not expire.
  Returns:
    The session
  See Also:
    `ISession`

### addNew

    public static ServletContextFactory addNew(javax.servlet.ServletContext kontext,
                                               javax.servlet.http.HttpServletRequest proxy,
                                               javax.servlet.http.HttpServletRequest req,
                                               javax.servlet.http.HttpServletResponse res)

  Create and add a new ContextFactory.

  Parameters:
    `req` - The HttpServletRequest
    `res` - The HttpServletResponse
  Returns:
    The created ContextFactory

### destroy

    public void destroy()

  Description copied from interface: `IContextFactory`
  Removes the context factory from the classloader's list of context factories and destroys its content.

  Specified by:
    `destroy` in interface `IContextFactory`
  Overrides:
    `destroy` in class `SimpleContextFactory`
  See Also:
    `IContextFactory.remove()`

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `SimpleContextFactory`

### createContext

    public java.lang.Object createContext()

  Return an emulated JSR223 context.

  Returns:
    The context.
  See Also:
    `SimpleContextFactory.getContext()`, `Context`