FileDocCategorySizeDatePackage
DaytimeServlet.javaAPI DocExample2975Tue Jan 25 10:45:14 GMT 2000None

DaytimeServlet

public class DaytimeServlet extends com.oreilly.servlet.RemoteDaemonHttpServlet implements DaytimeServer

Fields Summary
Constructors Summary
Methods Summary
public voiddestroy()

    // If you override destroy() you also have to call super.destroy()
    super.destroy();
  
public voiddoGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)

    // If the client says "format=object" then
    // send the Date as a serialized object
    if ("object".equals(req.getParameter("format"))) {
      ObjectOutputStream out = new ObjectOutputStream(res.getOutputStream());
      out.writeObject(getDate());
    }
    // Otherwise send the Date as a normal ASCII string
    else {
      PrintWriter out = res.getWriter();
      out.println(getDate().toString());
    }
  
public voiddoPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)

    doGet(req, res);
  
public java.util.DategetDate()

    return new Date();
  
public voidhandleClient(java.net.Socket client)

    new DaytimeConnection(this, client).start();
  
public voidinit(javax.servlet.ServletConfig config)

    // As before, if you override init() you have to call super.init()
    super.init(config);