jstrachan 01/07/24 12:16:36
Modified: io TODO.txt
io/examples/web babelfish.jsp file_write.jsp fortune.jsp
pipe.jsp pipe2.jsp soap.jsp soap_echo.jsp
xml_echo.jsp xmlrpc.jsp xmlrpc2.jsp xmlrpc3.jsp
xmlrpc_echo.jsp
io/examples/web/marketwatch market_indices.jsp
news_headlines.jsp quote.jsp symbol_info.jsp
io/examples/web/soap babelfish.jsp babelfish2.jsp
fortune.jsp
io/examples/web/test file_write.jsp test_pipe.jsp
test_pipe2.jsp
io/src/org/apache/taglibs/io URLHelper.java URLTag.java
io/xml io.xml
Removed: io/src/org/apache/taglibs/io SetTag.java
Log:
Improved the documentation of the io taglib, added a new <io:body> tag and also
added support for pluggable character encodings now
Revision Changes Path
1.2 +3 -3 jakarta-taglibs/io/TODO.txt
Index: TODO.txt
===================================================================
RCS file: /home/cvs/jakarta-taglibs/io/TODO.txt,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TODO.txt 2001/05/04 18:06:48 1.1
+++ TODO.txt 2001/07/24 19:16:35 1.2
@@ -1,8 +1,8 @@
-* Port the XSL tag library to use the PipeConsumer / PipeProducer interfaces
- and demonstrate efficient integration between the io and xsl libraries.
+* support configurable encoding...
-* Demonstrate the use of <io:set property="foo">Some value</io:set>
+* change the pipelining mechanism so that it does not use bean properties on the
tags
+ as this conflicts with the latest JSP spec.
* Handle multi-part posts to allow easy posting of files or resources.
For example:-
1.3 +2 -2 jakarta-taglibs/io/examples/web/babelfish.jsp
Index: babelfish.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/io/examples/web/babelfish.jsp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- babelfish.jsp 2001/05/05 17:18:18 1.2
+++ babelfish.jsp 2001/07/24 19:16:35 1.3
@@ -3,7 +3,7 @@
<io:http url="http://services.xmethods.net:80/perl/soaplite.cgi" action="POST">
<io:header name="SOAPAction" value="urn:xmethodsBabelFish#BabelFish"/>
<io:header name="Content-Type" value="text/xml"/>
- <io:pipe>
+ <io:body>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
@@ -14,5 +14,5 @@
</m:BabelFish>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
- </io:pipe>
+ </io:body>
</io:http>
1.3 +1 -1 jakarta-taglibs/io/examples/web/file_write.jsp
Index: file_write.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/io/examples/web/file_write.jsp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- file_write.jsp 2001/05/05 17:18:18 1.2
+++ file_write.jsp 2001/07/24 19:16:35 1.3
@@ -37,7 +37,7 @@
<h2>Now lets read it...</h2>
-<io:pipe reader="<%= new FileReader( file ) %>"/>
+<io:body reader="<%= new FileReader( file ) %>"/>
</body>
</html>
1.3 +2 -2 jakarta-taglibs/io/examples/web/fortune.jsp
Index: fortune.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/io/examples/web/fortune.jsp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- fortune.jsp 2001/05/05 17:18:18 1.2
+++ fortune.jsp 2001/07/24 19:16:35 1.3
@@ -3,7 +3,7 @@
<io:http url="http://www.lemurlabs.com/rpcrouter" action="POST">
<io:header name="SOAPAction" value="urn:lemurlabs-Fortune"/>
<io:header name="Content-Type" value="text/xml"/>
- <io:pipe>
+ <io:body>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
@@ -11,5 +11,5 @@
<m:getAnyFortune xmlns:m="urn:lemurlabs-Fortune"/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
- </io:pipe>
+ </io:body>
</io:http>
1.3 +7 -5 jakarta-taglibs/io/examples/web/pipe.jsp
Index: pipe.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/io/examples/web/pipe.jsp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- pipe.jsp 2001/05/05 17:18:18 1.2
+++ pipe.jsp 2001/07/24 19:16:35 1.3
@@ -5,9 +5,11 @@
--%>
<io:xmlrpc url="/xmlrpc_echo.jsp">
- <io:http url="/xml_echo.jsp" action="POST">
- <io:pipe>
- Treat this text as XML
- </io:pipe>
- </io:http>
+ <io:body>
+ <io:http url="/xml_echo.jsp" action="POST">
+ <io:body>
+ Treat this text as XML
+ </io:body>
+ </io:http>
+ </io:body>
</io:xmlrpc>
1.3 +2 -2 jakarta-taglibs/io/examples/web/pipe2.jsp
Index: pipe2.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/io/examples/web/pipe2.jsp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- pipe2.jsp 2001/05/05 17:18:20 1.2
+++ pipe2.jsp 2001/07/24 19:16:35 1.3
@@ -5,7 +5,7 @@
--%>
<io:http url="/xml_echo.jsp" action="POST">
- <io:pipe>
+ <io:body>
Treat this text as XML
- </io:pipe>
+ </io:body>
</io:http>
1.3 +2 -2 jakarta-taglibs/io/examples/web/soap.jsp
Index: soap.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/io/examples/web/soap.jsp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- soap.jsp 2001/05/05 17:18:20 1.2
+++ soap.jsp 2001/07/24 19:16:35 1.3
@@ -3,7 +3,7 @@
<io:soap
url="/soap_echo.jsp"
SOAPAction="urn:jakartaTagLibs#echo">
- <io:pipe>
+ <io:body>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
@@ -13,5 +13,5 @@
</m:foo>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
- </io:pipe>
+ </io:body>
</io:soap>
1.3 +1 -1 jakarta-taglibs/io/examples/web/soap_echo.jsp
Index: soap_echo.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/io/examples/web/soap_echo.jsp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- soap_echo.jsp 2001/05/05 17:18:20 1.2
+++ soap_echo.jsp 2001/07/24 19:16:35 1.3
@@ -20,6 +20,6 @@
</SOAP-ENV:Header>
<SOAP-ENV:Body>
- <io:pipe reader="<%= request.getReader() %>"/>
+ <io:body reader="<%= request.getReader() %>"/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
1.3 +1 -1 jakarta-taglibs/io/examples/web/xml_echo.jsp
Index: xml_echo.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/io/examples/web/xml_echo.jsp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- xml_echo.jsp 2001/05/05 17:18:20 1.2
+++ xml_echo.jsp 2001/07/24 19:16:35 1.3
@@ -2,6 +2,6 @@
<root>
<generator>Made by xml_echo web service</generator>
<text>
- <io:pipe reader="<%= request.getReader() %>"/>
+ <io:body reader="<%= request.getReader() %>"/>
</text>
</root>
1.3 +2 -2 jakarta-taglibs/io/examples/web/xmlrpc.jsp
Index: xmlrpc.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/io/examples/web/xmlrpc.jsp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- xmlrpc.jsp 2001/05/05 17:18:20 1.2
+++ xmlrpc.jsp 2001/07/24 19:16:35 1.3
@@ -1,6 +1,6 @@
<%@taglib uri="http://jakarta.apache.org/taglibs/io-1.0" prefix="io" %>
<io:xmlrpc url="/xmlrpc_echo.jsp">
- <io:pipe>
+ <io:body>
<methodCall>
<methodName>examples.getStateName</methodName>
<params>
@@ -9,7 +9,7 @@
</param>
</params>
</methodCall>
- </io:pipe>
+ </io:body>
</io:xmlrpc>
1.3 +2 -2 jakarta-taglibs/io/examples/web/xmlrpc2.jsp
Index: xmlrpc2.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/io/examples/web/xmlrpc2.jsp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- xmlrpc2.jsp 2001/05/05 17:18:20 1.2
+++ xmlrpc2.jsp 2001/07/24 19:16:35 1.3
@@ -1,6 +1,6 @@
<%@taglib uri="http://jakarta.apache.org/taglibs/io-1.0" prefix="io" %>
<io:xmlrpc url="/form_echo.jsp">
- <io:pipe>
+ <io:body>
<methodCall>
<methodName>examples.getStateName</methodName>
<params>
@@ -9,7 +9,7 @@
</param>
</params>
</methodCall>
- </io:pipe>
+ </io:body>
</io:xmlrpc>
1.3 +2 -2 jakarta-taglibs/io/examples/web/xmlrpc3.jsp
Index: xmlrpc3.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/io/examples/web/xmlrpc3.jsp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- xmlrpc3.jsp 2001/05/05 17:18:21 1.2
+++ xmlrpc3.jsp 2001/07/24 19:16:35 1.3
@@ -1,7 +1,7 @@
<%@taglib uri="http://jakarta.apache.org/taglibs/io-1.0" prefix="io" %>
<io:http url="/xmlrpc_echo.jsp"action="POST">
<io:header name="Content-Type" value="text/xml"/>
- <io:pipe>
+ <io:body>
<methodCall>
<methodName>do.something</methodName>
<params>
@@ -10,7 +10,7 @@
</param>
</params>
</methodCall>
- </io:pipe>
+ </io:body>
</io:http>
1.3 +1 -1 jakarta-taglibs/io/examples/web/xmlrpc_echo.jsp
Index: xmlrpc_echo.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/io/examples/web/xmlrpc_echo.jsp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- xmlrpc_echo.jsp 2001/05/05 17:18:21 1.2
+++ xmlrpc_echo.jsp 2001/07/24 19:16:35 1.3
@@ -22,7 +22,7 @@
<body>
- <io:pipe reader="<%= request.getReader() %>"/>
+ <io:body reader="<%= request.getReader() %>"/>
</body>
</methodResponse>
1.3 +2 -2 jakarta-taglibs/io/examples/web/marketwatch/market_indices.jsp
Index: market_indices.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/io/examples/web/marketwatch/market_indices.jsp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- market_indices.jsp 2001/05/05 17:18:23 1.2
+++ market_indices.jsp 2001/07/24 19:16:36 1.3
@@ -8,11 +8,11 @@
url="http://soap.marketwatch.com/soap.asp"
SOAPAction="urn:MarketWatch-com:vbSoap.MarketIndexes#GetIndexes">
<io:header name="SOAPMethodName"
value="urn:MarketWatch-com:vbSoap.MarketIndexes#GetIndexes"/>
- <io:pipe>
+ <io:body>
<SOAP:Envelope xmlns:SOAP="urn:schemas-xmlsoap-org:soap.v1">
<SOAP:Body>
<GetIndexes/>
</SOAP:Body>
</SOAP:Envelope>
- </io:pipe>
+ </io:body>
</io:soap>
1.3 +2 -2 jakarta-taglibs/io/examples/web/marketwatch/news_headlines.jsp
Index: news_headlines.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/io/examples/web/marketwatch/news_headlines.jsp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- news_headlines.jsp 2001/05/05 17:18:23 1.2
+++ news_headlines.jsp 2001/07/24 19:16:36 1.3
@@ -8,7 +8,7 @@
url="http://soap.marketwatch.com/soap.asp"
SOAPAction="urn:MarketWatch-com:vbSoap.News#GetBullets">
<io:header name="SOAPMethodName"
value="urn:MarketWatch-com:vbSoap.News#GetBullets"/>
- <io:pipe>
+ <io:body>
<SOAP:Envelope xmlns:SOAP="urn:schemas-xmlsoap-org:soap.v1">
<SOAP:Body>
<GetBullets>
@@ -18,5 +18,5 @@
</GetBullets>
</SOAP:Body>
</SOAP:Envelope>
- </io:pipe>
+ </io:body>
</io:soap>
1.3 +2 -2 jakarta-taglibs/io/examples/web/marketwatch/quote.jsp
Index: quote.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/io/examples/web/marketwatch/quote.jsp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- quote.jsp 2001/05/05 17:18:23 1.2
+++ quote.jsp 2001/07/24 19:16:36 1.3
@@ -8,7 +8,7 @@
url="http://soap.marketwatch.com/soap.asp"
SOAPAction="urn:MarketWatch-com:vbSoap.Quotes#GetQuote">
<io:header name="SOAPMethodName"
value="urn:MarketWatch-com:vbSoap.Quotes#GetQuote"/>
- <io:pipe>
+ <io:body>
<SOAP:Envelope xmlns:SOAP="urn:schemas-xmlsoap-org:soap.v1">
<SOAP:Body>
<GetQuote>
@@ -17,5 +17,5 @@
</GetQuote>
</SOAP:Body>
</SOAP:Envelope>
- </io:pipe>
+ </io:body>
</io:soap>
1.3 +2 -2 jakarta-taglibs/io/examples/web/marketwatch/symbol_info.jsp
Index: symbol_info.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/io/examples/web/marketwatch/symbol_info.jsp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- symbol_info.jsp 2001/05/05 17:18:23 1.2
+++ symbol_info.jsp 2001/07/24 19:16:36 1.3
@@ -8,7 +8,7 @@
url="http://soap.marketwatch.com/soap.asp"
SOAPAction="urn:MarketWatch-com:vbSoap.Symbols#GetSymbolInfo">
<io:header name="SOAPMethodName"
value="urn:MarketWatch-com:vbSoap.Symbols#GetSymbolInfo"/>
- <io:pipe>
+ <io:body>
<SOAP:Envelope xmlns:SOAP="urn:schemas-xmlsoap-org:soap.v1">
<SOAP:Body>
<GetSymbolInfo>
@@ -17,5 +17,5 @@
</GetSymbolInfo>
</SOAP:Body>
</SOAP:Envelope>
- </io:pipe>
+ </io:body>
</io:soap>
1.3 +2 -2 jakarta-taglibs/io/examples/web/soap/babelfish.jsp
Index: babelfish.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/io/examples/web/soap/babelfish.jsp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- babelfish.jsp 2001/05/05 17:18:24 1.2
+++ babelfish.jsp 2001/07/24 19:16:36 1.3
@@ -3,7 +3,7 @@
<io:soap
url="http://services.xmethods.net:80/perl/soaplite.cgi"
SOAPAction="urn:xmethodsBabelFish#BabelFish">
- <io:pipe>
+ <io:body>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
@@ -14,5 +14,5 @@
</m:BabelFish>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
- </io:pipe>
+ </io:body>
</io:soap>
1.3 +2 -2 jakarta-taglibs/io/examples/web/soap/babelfish2.jsp
Index: babelfish2.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/io/examples/web/soap/babelfish2.jsp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- babelfish2.jsp 2001/05/05 17:18:24 1.2
+++ babelfish2.jsp 2001/07/24 19:16:36 1.3
@@ -3,7 +3,7 @@
<io:soap
url="http://www.velocigen.com:82/vx_engine/soap-trigger.pperl"
SOAPAction="urn:vgx-translate">
- <io:pipe>
+ <io:body>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
@@ -16,5 +16,5 @@
</m:getTranslation>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
- </io:pipe>
+ </io:body>
</io:soap>
1.3 +2 -2 jakarta-taglibs/io/examples/web/soap/fortune.jsp
Index: fortune.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/io/examples/web/soap/fortune.jsp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- fortune.jsp 2001/05/05 17:18:25 1.2
+++ fortune.jsp 2001/07/24 19:16:36 1.3
@@ -3,7 +3,7 @@
<io:soap
url="http://www.lemurlabs.com/rpcrouter"
SOAPAction="urn:lemurlabs-Fortune">
- <io:pipe>
+ <io:body>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
@@ -11,5 +11,5 @@
<m:getAnyFortune xmlns:m="urn:lemurlabs-Fortune"/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
- </io:pipe>
+ </io:body>
</io:soap>
1.4 +2 -2 jakarta-taglibs/io/examples/web/test/file_write.jsp
Index: file_write.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/io/examples/web/test/file_write.jsp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- file_write.jsp 2001/07/24 17:59:08 1.3
+++ file_write.jsp 2001/07/24 19:16:36 1.4
@@ -12,9 +12,9 @@
</p>
<p>
<io:request url="file:/C:/foo.txt" output="false">
- <io:pipe>
+ <io:body>
This is some text - did it work?
- </io:pipe>
+ </io:body>
</io:request>
</p>
<p>
1.4 +3 -3 jakarta-taglibs/io/examples/web/test/test_pipe.jsp
Index: test_pipe.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/io/examples/web/test/test_pipe.jsp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- test_pipe.jsp 2001/07/24 17:59:08 1.3
+++ test_pipe.jsp 2001/07/24 19:16:36 1.4
@@ -2,7 +2,7 @@
<%@taglib uri="http://jakarta.apache.org/taglibs/io-1.0" prefix="io" %>
<%--
- Tests the behaviour of the <io:pipe> tag
+ Tests the behaviour of the <io:body> tag
--%>
<%
@@ -13,11 +13,11 @@
<h2>Pipe test</h2>
<pre>Here comes the data:-
-<io:pipe>
+<io:body>
<io:set property="pipeInput">
<io:get name="data"/>
</io:set>
-</io:pipe>
+</io:body>
</body>
</html>
1.4 +2 -2 jakarta-taglibs/io/examples/web/test/test_pipe2.jsp
Index: test_pipe2.jsp
===================================================================
RCS file: /home/cvs/jakarta-taglibs/io/examples/web/test/test_pipe2.jsp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- test_pipe2.jsp 2001/07/24 17:59:08 1.3
+++ test_pipe2.jsp 2001/07/24 19:16:36 1.4
@@ -2,7 +2,7 @@
<%@taglib uri="http://jakarta.apache.org/taglibs/io-1.0" prefix="io" %>
<%--
- Tests the behaviour of the <io:pipe> tag using an internal IO request
+ Tests the behaviour of the <io:body> tag using an internal IO request
--%>
<body>
@@ -10,7 +10,7 @@
<pre>
Here's the XML
-<io:pipe><io:request url="/xml/employees.xml"/></io:pipe>
+<io:body><io:request url="/xml/employees.xml"/></io:body>
</pre>
</body>
1.2 +9 -6 jakarta-taglibs/io/src/org/apache/taglibs/io/URLHelper.java
Index: URLHelper.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/io/src/org/apache/taglibs/io/URLHelper.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- URLHelper.java 2001/05/04 18:08:13 1.1
+++ URLHelper.java 2001/07/24 19:16:36 1.2
@@ -70,7 +70,7 @@
* URIs or full URLs.
*
* @author <a href="mailto:[EMAIL PROTECTED]">James Strachan</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class URLHelper {
@@ -80,24 +80,27 @@
if ( request instanceof HttpServletRequest ) {
return createURL( uri, (HttpServletRequest) request, context );
}
- else {
+ else if ( uri.startsWith( "/" ) ) {
int port = request.getServerPort();
String host = request.getServerName();
String protocol = "http";
return new URL( protocol, host, port, uri );
}
+ else {
+ return new URL(uri);
+ }
}
public static URL createURL(String uri, HttpServletRequest request,
ServletContext context) throws MalformedURLException {
- if ( uri.indexOf( ':' ) >= 0 ) {
- return new URL( uri );
- }
- else {
+ if ( uri.startsWith( "/" ) ) {
int port = request.getServerPort();
String host = request.getServerName();
String protocol = "http";
String path = request.getContextPath() + uri;
return new URL( protocol, host, port, path );
+ }
+ else {
+ return new URL( uri );
}
}
}
1.3 +27 -3 jakarta-taglibs/io/src/org/apache/taglibs/io/URLTag.java
Index: URLTag.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/io/src/org/apache/taglibs/io/URLTag.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- URLTag.java 2001/05/06 10:55:33 1.2
+++ URLTag.java 2001/07/24 19:16:36 1.3
@@ -79,13 +79,16 @@
/** A JSP Custom tag to make a URL request and output the response.
*
* @author <a href="mailto:[EMAIL PROTECTED]">James Strachan</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class URLTag extends AbstractTag implements PipeProducer, PipeConsumer {
/** URL to request */
private String url;
+ /** The encoding to use (defaults to JVM encoding) */
+ private String encoding;
+
/** URL connection */
private URLConnection connection;
@@ -221,9 +224,22 @@
//log( "input has been set to: " + this.input );
}
+ /** Sets the character encoding */
+ public void setEncoding(String encoding) {
+ this.encoding = encoding;
+ }
+
public Writer getURLWriter() throws IOException {
OutputStream out = getURLOutputStream();
- return (out != null) ? new OutputStreamWriter( out ) : null;
+ if ( out != null ) {
+ if ( encoding != null ) {
+ return new OutputStreamWriter( out, encoding );
+ }
+ else {
+ return new OutputStreamWriter( out );
+ }
+ }
+ return null;
}
public OutputStream getURLOutputStream() throws IOException {
@@ -233,7 +249,15 @@
public Reader getURLReader() throws IOException {
InputStream in = getURLInputStream();
- return (in != null) ? new InputStreamReader( in ) : null;
+ if ( in != null ) {
+ if ( encoding != null ) {
+ return new InputStreamReader( in, encoding );
+ }
+ else {
+ return new InputStreamReader( in );
+ }
+ }
+ return null;
}
public InputStream getURLInputStream() throws IOException {
1.5 +188 -39 jakarta-taglibs/io/xml/io.xml
Index: io.xml
===================================================================
RCS file: /home/cvs/jakarta-taglibs/io/xml/io.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- io.xml 2001/07/24 17:59:09 1.4
+++ io.xml 2001/07/24 19:16:36 1.5
@@ -80,14 +80,29 @@
<pre><![CDATA[
<io:http url="something" action="POST">
- <io:pipe>
+ <io:body>
data to be posted....
- </io:pipe>
+ </io:body>
</io:xmlrpc>
]]></pre>
<p>
-Here we use a nested <io:pipe> tag to capture its body content for the data
+We may also wish to specify some query parameters as well as some HTTP headers.
+</p>
+
+<pre><![CDATA[
+<io:http url="something" action="POST">
+ <io:param name="foo" value="123"/>
+ <io:param name="bar">123</io:param>
+ <io:header name="Content-Type" value="text/xml"/>
+ <io:body>
+ data to be posted....
+ </io:body>
+</io:xmlrpc>
+]]></pre>
+
+<p>
+Here we use a nested <io:body> tag to capture its body content for the data
to be posted. The IO tags can be "piped" together like unix processes such
that the data to be posted can be specified using an inner <io:request> tag.
For example the following example reads a file "foo.txt" and posts it to the
@@ -115,7 +130,7 @@
<pre><![CDATA[
<io:http url="someXmlRpcUrl">
<io:header name="Content-Type" value="text/xml"/>
- <io:pipe>
+ <io:body>
<methodCall>
<methodName>do.something</methodName>
<params>
@@ -124,7 +139,7 @@
</param>
</params>
</methodCall>
- </io:pipe>
+ </io:body>
</io:http>
]]></pre>
@@ -142,7 +157,7 @@
<pre><![CDATA[
<io:xmlrpc url="someXmlRpcUrl">
- <io:pipe>
+ <io:body>
<methodCall>
<methodName>do.something</methodName>
<params>
@@ -151,7 +166,7 @@
</param>
</params>
</methodCall>
- </io:pipe>
+ </io:body>
</io:xmlrpc>
]]></pre>
@@ -164,7 +179,7 @@
<io:soap
url="http://www.lemurlabs.com/rpcrouter"
SOAPAction="urn:lemurlabs-Fortune">
- <io:pipe>
+ <io:body>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
@@ -172,7 +187,7 @@
<m:getAnyFortune xmlns:m="urn:lemurlabs-Fortune"/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
- </io:pipe>
+ </io:body>
</io:soap>
]]></pre>
@@ -392,27 +407,6 @@
</p>
<p>
-Sometimes a transformer tag could accept multiple inputs (or outputs). This
-is rare but can happen. Currently there's an <xsl:apply> tag in the XSL tag
-library in the jakarta-taglibs project which does exactly this. To get
-around this problem the IO tag library has a tag called <io:set> which
-acts a little like the Unix "tee" command. It is a PipeConsumer so input can
-be piped into it, but it will use introspection on its outer tag to pass the
-Reader through the pipe. For example:-
-</p>
-
-<pre><![CDATA[
-<xsl:apply>
- <io:set property="xslReader">
- <io:request url="someStylesheet.xsl"/>
- </io:set>
- <io:set property="xmlReader">
- <io:request url="someXml.xml"/>
- </io:set>
-</xsl:apply>
-]]></pre>
-
-<p>
Here's an example of more intense pipelining,
</p>
@@ -421,7 +415,7 @@
<io:soap url="someSoapURL" SOAPAction="doSomething">
<xsl:apply xsl="xmlRpcToSoap.xsl">
<io:xmlrpc url="someXmlRpcUrl">
- <io:pipe>
+ <io:body>
<methodCall>
<methodName>do.something</methodName>
<params>
@@ -430,7 +424,7 @@
</param>
</params>
</methodCall>
- </io:pipe>
+ </io:body>
</io:xmlrpc>
</xsl:apply>
@@ -488,16 +482,35 @@
<name>url</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
+ <description>
+ The URL to request.
+ If the URL starts with '/' then it is
+ treated as a local http request
+ </description>
+ </attribute>
+ <attribute>
+ <name>encoding</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <description>
+ Sets the character encoding used for this request. If none is
specified then the JVM's default is used.
+ </description>
</attribute>
<attribute>
<name>output</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
+ <description>
+ If set to true the output is enabled otherwise the output from the
request is ignored.
+ </description>
</attribute>
<attribute>
<name>input</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
+ <description>
+ If set to true then input is enabled otherwise the input to the
request is ignored.
+ </description>
</attribute>
<restrictions>None</restrictions>
<example><usage>
@@ -522,12 +535,44 @@
<name>url</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
+ <description>
+ The URL to request.
+ If the URL starts with '/' then it is
+ treated as a local http request
+ </description>
</attribute>
<attribute>
<name>action</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
+ <description>
+ Defines the HTTP action, either GET, POST, PUT, HEAD or some extended
HTTP action such as the WEB-DAV protocol.
+ </description>
+ </attribute>
+ <attribute>
+ <name>encoding</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <description>
+ Sets the character encoding used for this request. If none is
specified then the JVM's default is used.
+ </description>
</attribute>
+ <attribute>
+ <name>output</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <description>
+ If set to true the output is enabled otherwise the output from the
request is ignored.
+ </description>
+ </attribute>
+ <attribute>
+ <name>input</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <description>
+ If set to true then input is enabled otherwise the input to the
request is ignored.
+ </description>
+ </attribute>
<script-variable>No</script-variable>
<restrictions>None</restrictions>
<example><usage>
@@ -545,19 +590,26 @@
<tag-class>org.apache.taglibs.io.URLHeaderTag</tag-class>
<body-content>JSP</body-content>
<description>
- Defines a URL / HTTP header for the current request tag.
- The value of the header can be specified as an attribute
+ Defines a URL or HTTP header for the current <request> or
<http> tag.
+ The value of the header can be specified via the value attribute
otherwise the value of the tags body is taken instead.
</description>
<attribute>
<name>name</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
+ <description>
+ Defines the name of the header to set.
+ </description>
</attribute>
<attribute>
<name>value</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
+ <description>
+ Defines the value of the header. If this attribute is not specified
then
+ the body of this tag is used instead.
+ </description>
</attribute>
<script-variable>No</script-variable>
<restrictions>None</restrictions>
@@ -568,6 +620,10 @@
<io:http url="http://jakarta.apache.org" action="GET"/>
<io:header name="Content-Type" value="text/xml"/>
</io:http>
+
+<io:http url="http://jakarta.apache.org" action="GET"/>
+ <io:header name="Content-Type">text/xml</io:header>
+</io:http>
]]></code>
</usage></example>
</tag>
@@ -586,11 +642,18 @@
<name>name</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
+ <description>
+ Defines the name of the URL query parameter.
+ </description>
</attribute>
<attribute>
<name>value</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
+ <description>
+ Defines the value of the URL query parameter. If this attribute is
not specified then
+ the body of this tag is used instead.
+ </description>
</attribute>
<script-variable>No</script-variable>
<restrictions>Must be specified before any <http:header> or
<http:body> tags</restrictions>
@@ -599,7 +662,8 @@
</comment>
<code><![CDATA[
<io:http url="http://jakarta.apache.org" action="GET"/>
- <io:header name="Content-Type" value="text/xml"/>
+ <io:param name="foo" value="123"/>
+ <io:param name="bar">123</io:param>
</io:http>
]]></code>
</usage></example>
@@ -617,12 +681,28 @@
<name>url</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
+ <description>
+ The SOAP endpoint URL.
+ If the URL starts with '/' then it is
+ treated as a local http request
+ </description>
</attribute>
<attribute>
<name>SOAPAction</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
+ <description>
+ The SOAP action to use
+ </description>
</attribute>
+ <attribute>
+ <name>encoding</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <description>
+ Sets the character encoding used for this request. If none is
specified then the JVM's default is used.
+ </description>
+ </attribute>
<script-variable>No</script-variable>
<restrictions>None</restrictions>
<example><usage>
@@ -661,12 +741,28 @@
<name>url</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
+ <description>
+ The XML-RPC endpoint URL.
+ If the URL starts with '/' then it is
+ treated as a local http request
+ </description>
</attribute>
<attribute>
<name>userAgent</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
+ <description>
+ The XML-RPC user agent
+ </description>
</attribute>
+ <attribute>
+ <name>encoding</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <description>
+ Sets the character encoding used for this request. If none is
specified then the JVM's default is used.
+ </description>
+ </attribute>
<script-variable>No</script-variable>
<restrictions>None</restrictions>
<example><usage>
@@ -692,32 +788,73 @@
<!-- pipe tag -->
<tag>
+ <name>body</name>
+ <tag-class>org.apache.taglibs.io.PipeTag</tag-class>
+ <body-content>JSP</body-content>
+ <description>
+ Contains the body of a HTTP POST, XML-RPC or SOAP request
+ which is sent so the URL as input.
+ </description>
+ <script-variable>No</script-variable>
+ <attribute>
+ <name>reader</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <description>
+ The Reader used to find the body to be used. If this
+ variable is not specified then the body of the current tag is used.
+ </description>
+ </attribute>
+ <restrictions></restrictions>
+ <example><usage>
+ <comment>
+ </comment>
+ <code><![CDATA[
+<io:http url="http://www.acme.com/foo" action="POST">
+ <io:body> this is the body to be posted </io:body>
+</io:http>
+
+<io:http url="http://www.acme.com/foo" action="POST">
+ <io:body reader="<%= request.getReader() %>"/>
+</io:http>
+]]></code>
+ </usage></example>
+ </tag>
+
+ <!-- pipe tag -->
+ <tag>
<name>pipe</name>
<tag-class>org.apache.taglibs.io.PipeTag</tag-class>
<body-content>JSP</body-content>
<description>
Acts like a Unix pipe between tags that are not capable of piping
themselves.
A pipe can take some input or some output or both.
- If no input is specified then its body content is used.
- If no output is specified then the current output is used.
</description>
<script-variable>No</script-variable>
<attribute>
<name>reader</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
+ <description>
+ The Reader used to find the input to be used. If this
+ variable is not specified then the body of the current tag is used.
+ </description>
</attribute>
<attribute>
<name>writer</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
+ <description>
+ The Writer to be used as the destination of the pipe.
+ If this variable is not specified then the current output is used
instead.
+ </description>
</attribute>
<restrictions></restrictions>
<example><usage>
<comment>
</comment>
<code><![CDATA[
-<io:pipe input="<%= request.getReader() %>"/>
+<io:body reader="<%= request.getReader() %>"/>
]]></code>
</usage></example>
</tag>
@@ -735,11 +872,17 @@
<name>name</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
+ <description>
+ The name of the attribute to look up
+ </description>
</attribute>
<attribute>
<name>property</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
+ <description>
+ The optional bean property name
+ </description>
</attribute>
<restrictions></restrictions>
<example><usage>
@@ -760,7 +903,13 @@
Clean up of tag library prior to performing a beta
release, moving toward an official release.
</description>
- <section name="Tag removed">
+ <section name="New features">
+ <item>
+ Plugable character encoding is now available via the <i>encoding</i>
attribute on the <io:request> <io:http> <io:xmlrpc> and
<io:soap> tags
+ </item>
+ <item>
+ For simplicitly the <io:body> has been added back again. This makes
http requests in the taglib more natural.
+ </item>
<item>
The <io:set> tag has been removed since it appears that
tags are not allowed to set properties on their outer tags as this