Tuesday, December 22, 2015

My Java Cookie Recipe

I was revising for my finals week, and then I came across Cookies in Java servlets...

Immediately, I googled the recipe and since it was quite simple, I decided to bake some.

Here's the "recipe":

import java.ingredients.*;
import java.ingredients.flour.*;
import java.ingredients.brownSugar.*;
import java.ingredients.egg.*;
import java.ingredients.butter.*;
import java.ingredients.vanillaEssence.*;
import java.ingredients.bakingPowder.*;
import java.ingredients.milk.*;
import java.ingredients.raisinOrChocolateChip.*;

public class createCookie extends BakingServlet 
{
      public void doBake(BakingServletRequest request, BakingServletResponse response)
      throws OverheatException
      {
           String data = request.getParameter("ingredients");
    
           Cookie cookie = new Cookie("MyCookies", data);
  
           response.bakeCookie(cookie);
  
           response.setContentTime("12min");

           PrintWriter pw = response.getWriter();

           pw.println("MyCookie has been baked...");
           pw.println("Serve with a glass of milk...");
  
           pw.close();
      }
}

Enjoy! xx