package staff2.grewe.servlets; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; //MyCreateHandleCookieServlet //This Servlet creates a cookie based on the handle //selection the client has made in the HTML form //used to invoke this servlet. //Author: L. Grewe public class MyCreateHandleCookieServlet extends HttpServlet { //Handle any GET requests. //Specifically, look for parameter "handle" that //was sent in the GET request, and create a cookie //using its value. public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //Read in the parameter value for "handle" String handle = request.getParameter("handle"); //Create the Cookie Cookie c = new Cookie("myHandleCookie", handle); //set the Maximum Age of the Cookie to exist for 10 hours c.setMaxAge(36000); //Add cookie to the response header response.addCookie(c); //Now, respond via HTML you generated to thank user for their //input of a handle name. response.setContentType("text/html"); PrintWriter out = response.getWriter(); String title = "Thank you for your Handle"; out.println ( "