FileDocCategorySizeDatePackage
BurritoInventoryConsumer.javaAPI DocExample909Tue Jan 25 10:45:14 GMT 2000None

BurritoInventoryConsumer.java

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class BurritoInventoryConsumer extends HttpServlet {

  // Get (and keep!) a reference to the shared BurritoInventory instance
  private BurritoInventory inventory = BurritoInventory.getInstance();

  public void doGet(HttpServletRequest req, HttpServletResponse res)
                               throws ServletException, IOException {
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();

    out.println("<HTML>");
    out.println("<HEAD><TITLE>Burrito Inventory Consumer</TITLE></HEAD>");

    out.println("<BODY><BIG>");

    if (inventory.makeBurrito()) {
      out.println("Your burrito will be ready in a few minutes.");
    }
    else {
      out.println("We're low on ingredients.<BR>");
      out.println("Looks like you're gonna starve.");
    }

    out.println("</BIG></BODY></HTML>");
  }
}