HTTP HEAD taglib ver. 1.2

    Custom JSP tags library lets you perform HTTP HEAD requests. Tag HttpHead lets you request for example size and content type for the remote file, check HTTP status code (file existence) as well as modification date. E.g.:
 


<%@ taglib uri="taglib.tld" prefix="h" %>

<h:HttpHead url="http://www.servletsuite.com/servlets/sos.zip" id="A"/>

file size: <%=A.get("contentLength")%>

Optional attribute id describes a name for the page scope variable (type is java.util.HashMap) with the requested attributes. You can check out the following keys:

responseCode - HTTP status code. E.g. 200 - file exists, 404 - file not found etc.
contentType - content type for the file
contentLength - content length (file size) in bytes
lastModified - modification date

Without id attribute tag prints the requested data in JSON format. E.g.:


<%@ taglib uri="taglib.tld" prefix="h" %>

<script language="JavaScript">
var s = <h:HttpHead url="http://servletsuite.com/servlets/sos.zip"/>;
var o = eval("("+s+")");
alert("Content type is:"+o.contentType);
</script>

Tags are:

HttpHead

Tag performs HTTP HEAD request. Attributes are:

1) url Describes an URL for the remote file (host)
2) id Optional attribute. Describes a name for the page scope variable with the requested data
3) redirect Optional attribute. Describes a boolean value: follow/do not follow to redirect code on the requested site. Default value is true (follow to redirect)

for downloading:

Library: httpheadtag.jar    Description: taglib.tld

 © Coldbeans      Comments?

See also Coldtags suite - the largest collection of custom JSP tags.

Also in Coldtags: