title: HttpServletRequest.getCookies(): Array, Why The isHttpOnly() function always return false?
body: <p>hi I'm trying to have httponly cookies so far this is the code that I've written </p>
  
  <pre><code>protected void doGet(HttpServletRequest req, HttpServletResponse resp)
          throws ServletException, IOException {
      resp.setContentType("text/html");
      PrintWriter out = resp.getWriter();
  
      Cookie cookie = new Cookie("mycookie", "hi");
      resp.addCookie(cookie);
  
      cookie.setHttpOnly(true);
      boolean bol = cookie.isHttpOnly();
      out.println("&lt;br&gt;Cookie is Marked as HttpOnly = " + bol);
      Cookie[] cookies = req.getCookies();
      if (cookies != null) {
          for (int i = 0; i &lt; cookies.length; i++) {
  
          out.println("&lt;br/&gt; From Cookies Array Name is: " 
              + cookies[i].getName());
          out.println("&lt;br/&gt; From Cookies Array Value is: "
              + cookies[i].getValue());
          out.println("&lt;br/&gt; From Cookies Array isHttpOnly: "
              + cookies[i].isHttpOnly());
          }
      }
      out.println("&lt;br/&gt; &lt;br/&gt;");
  
      cookie.setHttpOnly(false);
      boolean bol1 = cookie.isHttpOnly();
      out.println("&lt;br&gt;Cookie is Marked as HttpOnly = " + bol1);
      Cookie[] cookies1 = req.getCookies();
      if (cookies1 != null) {
          for (int i = 0; i &lt; cookies1.length; i++) {
          out.println("&lt;br/&gt; From Cookies Array Name is: "
              + cookies[i].getName());
          out.println("&lt;br/&gt; From Cookies Array Value is: "
              + cookies[i].getValue());
          out.println("&lt;br/&gt; From Cookies Array isHttpOnly: "
              + cookies[i].isHttpOnly());
          }
      }
      out.close();
  }
  </code></pre>
  
  <p>Prints </p>
  
  <pre><code>    Cookie is Marked as HttpOnly = true
  From Cookies Array Name is: mycookie
  From Cookies Array Value is: hi
  From Cookies Array isHttpOnly: false
  
  
  Cookie is Marked as HttpOnly = false
  From Cookies Array Name is: mycookie
  From Cookies Array Value is: hi
  From Cookies Array isHttpOnly: false 
  </code></pre>
  
  <p>Note that I'm using JBoss 7, and in web.xml config I've added but I think something is missing</p>
  
  <pre><code>&lt;session-config&gt;
          &lt;cookie-config&gt;
              &lt;http-only&gt;true&lt;/http-only&gt;
          &lt;/cookie-config&gt;
      &lt;/session-config&gt;
  </code></pre>