HTTP taglib ver. 2.2

    Custom JSP tags. This taglib lets you proceed HTTP requests. Options include data caching and asynchronous execution.

For example:
 


<%@ taglib uri="taglib.tld" prefix="do" %>
<html>

<!-- do GET and save output in the page scope variable -->
<do:GetPost url="www.acme.com/cgi-bin/script" method="get" id="A"/>
<%=A%>

<!-- do GET and save dowloaded file -->
<do:GetPost url="www.acme.com/data/picture.gif" method="get" localPath="c:/images" />

<!-- do POST asynchronously -->
<do:GetPost url="www.acme.com/cgi-bin/script" method="post" asynch="true">
    <do:setParam name="A" value="12345"/>
    <do:setParam name="B" value="5678"/>
</do:GetPost>

<!-- if you did not set parameters body will be posted -->
<do:GetPost url="www.webservice.net/script" method="post">
 <this_XML_stuff>
   <will_be_posted/>
 </this_XML_stuff>
</do:GetPost>

<!-- do GET and use cache for 10 min -->
<do:GetPost url="www.acme.com/cgi-bin/script" ttl="600" id="A"/>
<%=A%>

</html>

Tags are:

GetPost

Proceeds HTTP request. Parameters are:

1) url URL for your request
2) method Describes a type for your request. Possible values are get or post. Default value is get.
3) id Optional attribute. Describes a name for page scope variable (type is java.lang.String) that will keep the result of your request. By default tag will simply print the requested data.
4) ttl Optional parameter: caching time (in seconds). Default value is 0 (no cache)
5) scope Optional parameter: scope for cache. Possible values are application or session. Default value is application (cache will be used if you set ttl parameter).
6) asynch mode of request. Possible values are true or false. Default value is false (synchronous mode).
7) localPath Optional parameter. If you set this parameter than tag will save downloaded data in the local file system. Parameter describes some file path (file will be created) or some existing directory. By default is empty (do not save data).
8) timeout Optional parameter. Describes a timeout for your request (in milliseconds).
9) proxyHost Optional parameter. Describes proxy settings for your system.
10) proxyPort Optional parameter. Describes proxy settings for your system.
11) encoding Optional parameter. Describes an encoding for the request.

setParam

Body tag lets you define a parameter for HTTP POST request. Body describes parameter's value.

1) name describes a name for your parameter
2) value Optional parameter. Describes a value for this parameter

setHeader

Body tag lets you define a header for your request

1) name describes a name for your header
2) value Optional parameter. Describes a value for this header

setAuthorization

Sets user name/password for basic authentication

1) user user name
2) password password
 

for downloading:

    Library: httptag.jar    Description: taglib.tld

© Coldbeans      Comments?

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

Also in Coldtags: