Set a Cookie from a servletTag(s): Servlet/JSP


import javax.servlet.*;
import javax.servlet.http.*;

public class MyServlet extends HttpServlet {
  public void doPost(HttpServletRequest req, HttpServletResponse res) {
    res.addCookie(new Cookie("mycookie_name", "mycookie_value"));
    }
    
  public void doGet(HttpServletRequest req, HttpServletResponse res) {
    doPost(req, res);
    }
    
}


blog comments powered by Disqus