Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8036017

Set-Cookie response header is read as empty after setting CookieManager

XMLWordPrintable

      1) Create a URL to a simple JSP (say HelloWorld.jsp) deployed in Web Server
      that maintains session (say TomCat).
      2) Create a CookieManager which accepts all cookies as given below:

            CookieManager manager = new CookieManager ();
            manager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
            CookieHandler.setDefault(manager);

      3) ReadResponse
         - Open connection and read response headers and body from the
      URLConnection.
         - Write the response headers/body to the console.
         - We find that Set-Cookie header has empty value.

      4) Repeat step #3

      Note: Please find MyCookieTest.java (attached) executing the above steps.

      Observation
      ===========
      From the response of step #3, we find that Set-cookie header has an empty
      value. However, from the contents of the CookieStore we find that the
      JSESSIONID cookie is stored (as expected).

      From the response of step #4, we find that Set-cookie header is absent and
      the session is maintained ( as expected).

      Test Files
      ==========
      Please find the test case MyCookieTest.java and HelloWorld.jsp attached.

        1. Output.txt
          1 kB
        2. MyCookieTest.java
          3 kB
        3. HelloWorld.jsp
          0.2 kB

            dmeetry Dmeetry Degrave (Inactive)
            asaha Abhijit Saha
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: