1

I'm trying to set a cookie in a custom taglib, but I never see the cookie reach the browser. Is this a limitation of custom tags?

@Override
  public int doStartTag() throws JspException {
    ServletResponse res = pageContext.getResponse();
    Cookie cookie = new Cookie("asb", "12345");
    cookie.setDomain(".domain.com");
    ((HttpServletResponse) res).addCookie(cookie);   
    return SKIP_BODY;
  }
Nath
  • 6,774
  • 2
  • 28
  • 22
  • It may be something to do with the way the custom tag will be executed by the Servlet engine. There is a clue in this post - http://stackoverflow.com/questions/7532494/unable-to-add-a-cookie-included-in-jsp-via-jspinclude – ramp Aug 11 '15 at 11:16
  • It looks like there is an issue in the app where the tag is used. A new clean java web project and this tag works fine. – Nath Aug 11 '15 at 13:16

0 Answers0