Get header from HttpUrlConnection object

Make sure you are getting the successful response before you try to fetch the headers. This is how you can check for your response:

int status = conn.getResponseCode();

if (status == HttpURLConnection.HTTP_OK) {
    String header = conn.getHeaderField("MyHeader");
}

Also make sure the Servlet response is not a redirect response, if redirected all the session information, including headers will be lost.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)