You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by "Khalid K." <jk...@yahoo.com> on 2006/03/27 21:22:16 UTC

HeadMethod last-modified header null

Hi all,

I am trying to use HeadMethod to get 'last-modified'
header from response, and it always returns NULL.

Doesn't matter what site/page is passed to the
constructor, see the code below.

a very rough test (calling from jsp), any help is
appreciated :)

<%
System.out.println("calling head");
HeadMethod head = new
HeadMethod("http://jakarta.apache.org/commons/httpclient/apidocs/index.html");
if (head == null)  {
	System.out.println("head is null");
	return;
	}

Header header =
head.getResponseHeader("last-modified");
if (header == null) {
	System.out.println("header for last-modified is
null");
	return;
}
String lastModified =
head.getResponseHeader("last-modified").getValue();
System.out.println(lastModified);
%>

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Re: HeadMethod last-modified header null

Posted by "Khalid K." <jk...@yahoo.com>.
Nevermind, i had forgotten to:
HttpClient client = new HttpClient();
client.executeMethod(head);

:)



--- "Khalid K." <jk...@yahoo.com> wrote:

> Hi all,
> 
> I am trying to use HeadMethod to get 'last-modified'
> header from response, and it always returns NULL.
> 
> Doesn't matter what site/page is passed to the
> constructor, see the code below.
> 
> a very rough test (calling from jsp), any help is
> appreciated :)
> 
> <%
> System.out.println("calling head");
> HeadMethod head = new
>
HeadMethod("http://jakarta.apache.org/commons/httpclient/apidocs/index.html");
> if (head == null)  {
> 	System.out.println("head is null");
> 	return;
> 	}
> 
> Header header =
> head.getResponseHeader("last-modified");
> if (header == null) {
> 	System.out.println("header for last-modified is
> null");
> 	return;
> }
> String lastModified =
> head.getResponseHeader("last-modified").getValue();
> System.out.println(lastModified);
> %>
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam
> protection around 
> http://mail.yahoo.com 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> httpclient-user-help@jakarta.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org