protected Continuation getContinuation(Reader reader, ScriptContext context) throws IOException {
    HeaderParser headerParser =
        HeaderParser.DEFAULT_HEADER_PARSER; // ignore encoding, we pass everything directly
    IPhpScriptContext phpScriptContext = (IPhpScriptContext) context;
    updateGlobalEnvironment(context);
    OutputStream out = ((PhpScriptWriter) (context.getWriter())).getOutputStream();
    OutputStream err = ((PhpScriptWriter) (context.getErrorWriter())).getOutputStream();

    /*
     * encode according to content-type charset
     */
    if (out instanceof WriterOutputStream)
      headerParser = new SimpleHeaderParser((WriterOutputStream) out);

    Continuation kont =
        phpScriptContext.createContinuation(
            reader,
            env,
            out,
            err,
            headerParser,
            resultProxy = new ResultProxy(this),
            Util.getLogger(),
            isCompiled);

    phpScriptContext.setContinuation(kont);
    phpScriptContext.startContinuation();
    return kont;
  }
  /** Create a new context ID and a environment map which we send to the client. */
  protected void setNewContextFactory() {
    env = (Map) getProcessEnvironment().clone();

    addNewContextFactory();

    // short path S1: no PUT request
    ContextServer contextServer = getContextServer();
    AbstractChannelName channelName = contextServer.getChannelName(ctx);
    if (channelName != null) {
      env.put("X_JAVABRIDGE_REDIRECT", channelName.getName());
      ctx.getBridge();
      contextServer.start(channelName, Util.getLogger());
    }

    setStandardEnvironmentValues(env);
  }