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.
bodyDefines the HTTP body for the current HTTP request tag.
soap Performs a HTTP SOAP request on the given URL, SOAPAction and body.
 

Tag Reference

requestAvailability: version 1.0
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 Classorg.apache.taglibs.http.HttpRequestTag
Tag BodyJSP
Script VariableNo
RestrictionsNone
Attributes 
 
NameRequiredRuntime Expression Evaluation
urltruetrue
actionfalsetrue
Example
  1. <%-- --%>

    <http:request url="http://jakarta.apache.org" action="GET"/>

headerAvailability: 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 Classorg.apache.taglibs.http.HttpHeaderTag
Tag BodyJSP
Script VariableNo
RestrictionsNone
Attributes 
 
NameRequiredRuntime Expression Evaluation
nametruetrue
valuefalsetrue
Example
  1. <%-- --%>

    <http:request url="http://jakarta.apache.org" action="GET"/> <http:header name="Content-Type" value="text/xml"/> </http:request>

paramAvailability: 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 Classorg.apache.taglibs.http.HttpParameterTag
Tag BodyJSP
Script VariableNo
RestrictionsMust be specified before any <http:header> or <http:body> tags
Attributes 
 
NameRequiredRuntime Expression Evaluation
nametruetrue
valuefalsetrue
Example
  1. <%-- --%>

    <http:request url="http://jakarta.apache.org" action="GET"/> <http:header name="Content-Type" value="text/xml"/> </http:request>

bodyAvailability: version 1.0
Defines the HTTP body for the current HTTP request tag.
 
Tag Classorg.apache.taglibs.http.HttpBodyTag
Tag BodyJSP
Script VariableNo
RestrictionsMust be specified after any <http:param> or <http:header> tags
AttributesNone
Example
  1. <%-- --%>

    <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>

soapAvailability: version 1.0
Performs a HTTP SOAP request on the given URL, SOAPAction and body.
 
Tag Classorg.apache.taglibs.http.HttpSoapRequestTag
Tag BodyJSP
Script VariableNo
RestrictionsNone
Attributes 
 
NameRequiredRuntime Expression Evaluation
urltruetrue
SOAPActiontruetrue
Example
  1. <%-- --%>

    <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.