jstrachan 01/07/25 12:05:15
Modified: io/src/org/apache/taglibs/io URLTag.java
Log:
Fixed bug spotted by Shawn Bayern where the <io:param> was incorrectly causing the
url property to change. Now a different property is used instead thus the tag is now
not breaking the JSP1.2 spec
Revision Changes Path
1.4 +16 -8 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- URLTag.java 2001/07/24 19:16:36 1.3
+++ URLTag.java 2001/07/25 19:05:14 1.4
@@ -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.3 $
+ * @version $Revision: 1.4 $
*/
public class URLTag extends AbstractTag implements PipeProducer, PipeConsumer {
- /** URL to request */
+ /** URL property to request */
private String url;
+ /** The current full URL including any <io:param> tags */
+ private String fullURL;
+
/** The encoding to use (defaults to JVM encoding) */
private String encoding;
@@ -128,12 +131,17 @@
/** Adds a HTTP query parameter to the current url
*/
public void addParameter( String name, String value ) {
- String prefix = ( url.indexOf( '?' ) < 0 ) ? "?" : "&";
- url += prefix + name + "=" + value;
+ if ( fullURL == null ) {
+ fullURL = url;
+ }
+ String prefix = ( fullURL.indexOf( '?' ) < 0 ) ? "?" : "&";
+ fullURL += prefix + name + "=" + value;
+ // XXXX: may wish to add some encoding code here...
+
if ( TRACE ) {
log( "Adding parameter: " + name + ": " + value );
- log( "URL is now: " + url );
+ log( "URL is now: " + fullURL );
}
}
@@ -155,13 +163,12 @@
// Tag interface
//-------------------------------------------------------------------------
public int doStartTag() throws JspException {
+ fullURL = null;
connection = null;
return EVAL_BODY_INCLUDE;
}
public int doEndTag() throws JspException {
- //log( "#### doEndTag: reader: " + reader + " writer: " + writer + "
output: " + output + " input: " + input );
-
Writer writer = null;
try {
if ( reader != null ) {
@@ -199,6 +206,7 @@
public void release() {
super.release();
url = null;
+ fullURL = null;
connection = null;
buffer = null;
input = false;
@@ -271,7 +279,7 @@
//-------------------------------------------------------------------------
protected URLConnection getConnection() throws IOException {
if ( connection == null ) {
- URL theURL = URLHelper.createURL(url, pageContext);
+ URL theURL = URLHelper.createURL(fullURL, pageContext);
if ( TRACE ) {
log( "Reading URL: " + theURL.toString() );