Jakarta Project: HTTP Tag library
Version: 1.0
Table of Contents
Overview
Requirements
Configuration
Tag Summary
Tag Reference
Examples
Javadocs
Revision History
Overview
The HTTP tag library allows HTTP requests to be performed using JSP
custom tags. This allows JSP to be used to perform HTTP GETs or PUT
operations for example to make SOAP requests.
Requirements
This custom tag library requires no software other than a servlet container
that supports the JavaServer Pages Specification, version 1.1 or higher.
Configuration
Follow these steps to configure your web application with this tag library:
To use the tags from this library in your JSP pages, add the following
directive at the top of each page:
<%@ taglib uri="http://jakarta.apache.org/taglibs/http-1.0" prefix="http" %>
where "http" is the tag name prefix you wish to use for tags
from this library. You can change this value to any prefix you like.
Tag Summary
| request |
Performs a HTTP request on the given URL with the specified action and optional body.
If no action is specified then it defaults to "GET".
|
| header |
Defines a HTTP header for the current HTTP request tag.
The value of the header can be specified as an attribute
otherwise the value of the tags body is taken instead.
|
| param |
Defines a HTTP query argument for the URL of the current HTTP request.
The value of the parameter can be specified as an attribute
otherwise the value of the tags body is taken instead.
|
| body | Defines the HTTP body for the current HTTP request tag. |
| soap |
Performs a HTTP SOAP request on the given URL, SOAPAction and body.
|
| |
Tag Reference
|
|
|
Performs a HTTP request on the given URL with the specified action and optional body.
If no action is specified then it defaults to "GET".
|
| |
| Tag Class | org.apache.taglibs.http.HttpRequestTag |
| Tag Body | JSP |
| Script Variable | No |
| Restrictions | None |
| Attributes | |
| |
| Name | Required | Runtime Expression Evaluation |
| url | true | true |
|
| action | false | true |
|
|
| Example |
-
<http:request url="http://jakarta.apache.org" action="GET"/>
|
|
| header | Availability: version 1.0 |
|
|
Defines a HTTP header for the current HTTP request tag.
The value of the header can be specified as an attribute
otherwise the value of the tags body is taken instead.
|
| |
| Tag Class | org.apache.taglibs.http.HttpHeaderTag |
| Tag Body | JSP |
| Script Variable | No |
| Restrictions | None |
| Attributes | |
| |
| Name | Required | Runtime Expression Evaluation |
| name | true | true |
|
| value | false | true |
|
|
| Example |
-
<http:request url="http://jakarta.apache.org" action="GET"/>
<http:header name="Content-Type" value="text/xml"/>
</http:request>
|
|
| param | Availability: version 1.0 |
|
|
Defines a HTTP query argument for the URL of the current HTTP request.
The value of the parameter can be specified as an attribute
otherwise the value of the tags body is taken instead.
|
| |
| Tag Class | org.apache.taglibs.http.HttpParameterTag |
| Tag Body | JSP |
| Script Variable | No |
| Restrictions | Must be specified before any <http:header> or <http:body> tags |
| Attributes | |
| |
| Name | Required | Runtime Expression Evaluation |
| name | true | true |
|
| value | false | true |
|
|
| Example |
-
<http:request url="http://jakarta.apache.org" action="GET"/>
<http:header name="Content-Type" value="text/xml"/>
</http:request>
|
|
| body | Availability: version 1.0 |
|
| Defines the HTTP body for the current HTTP request tag. |
| |
| Tag Class | org.apache.taglibs.http.HttpBodyTag |
| Tag Body | JSP |
| Script Variable | No |
| Restrictions | Must be specified after any <http:param> or <http:header> tags |
| Attributes | None |
| Example |
-
<http:request url="http://services.xmethods.net:80/perl/soaplite.cgi" action="POST">
<http:header name="SOAPAction" value="urn:xmethodsBabelFish#BabelFish"/>
<http:header name="Content-Type" value="text/xml"/>
<http:body>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<m:BabelFish xmlns:m="urn:xmethodsBabelFish">
<translationmode>en_fr</translationmode>
<sourcedata>SOAP is quite easy with JSP.</sourcedata>
</m:BabelFish>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
</http:body>
</http:request>
|
|
| soap | Availability: version 1.0 |
|
|
Performs a HTTP SOAP request on the given URL, SOAPAction and body.
|
| |
| Tag Class | org.apache.taglibs.http.HttpSoapRequestTag |
| Tag Body | JSP |
| Script Variable | No |
| Restrictions | None |
| Attributes | |
| |
| Name | Required | Runtime Expression Evaluation |
| url | true | true |
|
| SOAPAction | true | true |
|
|
| Example |
-
<http:soap
url="http://services.xmethods.net:80/perl/soaplite.cgi"
SOAPAction="urn:xmethodsBabelFish#BabelFish">
<http:body>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<m:BabelFish xmlns:m="urn:xmethodsBabelFish">
<translationmode>en_fr</translationmode>
<sourcedata>SOAP is quite easy with JSP.</sourcedata>
</m:BabelFish>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
</http:body>
</http:soap>
|
|
Examples
See the example application http-examples.war for examples of the usage
of the tags from this custom tag library.
Java Docs
Java programmers can view the java class documentation for this tag library
as javadocs.
Revision History
Review the complete revision history of this tag
library.