/**
 * @license
 * Copyright 2017 The FOAM Authors. All Rights Reserved.
 * http://www.apache.org/licenses/LICENSE-2.0
 */

package foam.nanos.http;

import com.sun.net.httpserver.*;
import java.io.*;
import java.util.Date;

public class PingService
  implements HttpHandler
{
  public PingService() {}

  @Override
  public void handle(HttpExchange t) throws IOException {
    System.out.println("Pong");
    String response = "Pong: " + new Date();
    t.sendResponseHeaders(200, response.length());
    OutputStream os = t.getResponseBody();
    os.write(response.getBytes());
    os.close();
  }
}

/**
 * @license
 * Copyright 2017 The FOAM Authors. All Rights Reserved.
 * http://www.apache.org/licenses/LICENSE-2.0
 */

package foam.nanos.http;

import foam.core.*;
import java.io.PrintWriter;
import java.util.Date;

public class PingService
  implements WebAgent
{
  public PingService() {}

  @Override
  public void execute(X x) {
    PrintWriter out = x.get(PrintWriter.class);
    out.println("Pong: " + new Date());
  }
}

Fix PingService by making a WebAgent.