Below is my Java code for creating javax.servlet.http.Cookie
from Tomcat 7 API
Cookie c = new Cookie("code", code.trim());
c.setPath("/public");
response.addCookie(c);
response.setStatus(200);
Am trying to add c.setHttpOnly(true);
to make the above code sonar compliant but Eclipse is throwing a compiler error saying he method setHttpOnly(boolean) is undefined for the type Cookie
, but from the Javadoc of Tomcat 7 API https://tomcat.apache.org/tomcat-7.0-doc/servletapi/index.html
I do see that setHttpOnly()
exists in Cookie
class, can someone please help me Understand why am I getting the compiler error for adding c.setHttpOnly(true);
?