I set up a connection to a server and it gives me a response. This response has two header keys but when I loop through like so many reference and how-to sites tell me I only get one and its the last value.
This is some code that I'm using:
for (int i=1; (headerName = conn.getHeaderFieldKey(i))!=null; i++) {
System.out.println(headerName);
if (headerName.equals("Set-Cookie")) {
cookie += conn.getHeaderField(i); }
}
Has anyone attempted this successfully? This code was copy and pasted from an example claimed to work but I used it myself and it doesn't work.
This is the response message:
HTTP/1.1 302 Moved Temporarily
Date: Mon, 16 Feb 2009 03:47:47 GMT
Server: Apache
Set-Cookie: JSESSIONID=E7C54E0ECE8CCFD89EF91FF8A47E34BC; Path=/
Location: http://<SITEURL>/redirecting.jsp
Content-Length: 0
P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE PSA"
Keep-Alive: timeout=15, max=15
Connection: Keep-Alive
Content-Type: text/html;charset=ISO-8859-1
Set-Cookie: BIGipServerI2O_pool_A=1815557130.20480.0000; path=/