webwork/src/main/webwork/view/taglib IncludeTag.java,1.23,1.24 URLTag.java,1.26,1.27
[email protected] Tue, 16 May 2006 00:34:10 -0700
| Newsgroups | gmane.comp.java.open-symphony.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/opensymphony/webwork/src/main/webwork/view/taglib
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv22536/src/main/webwork/view/taglib
Modified Files:
IncludeTag.java URLTag.java
Log Message:
Encode URLs using webwork's encoding, and not the system encoding. This fixes a number of bugs in JIRA :)
I'd raise an issue in Webwork's JIRA instance, but I can't seem to find it now...
Index: IncludeTag.java
===================================================================
RCS file: /cvsroot/opensymphony/webwork/src/main/webwork/view/taglib/IncludeTag.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- IncludeTag.java 7 Jan 2006 01:34:18 -0000 1.23
+++ IncludeTag.java 16 May 2006 07:34:08 -0000 1.24
@@ -6,8 +6,9 @@
*/
package webwork.view.taglib;
-import webwork.config.Configuration;
import webwork.util.FastByteArrayOutputStream;
+import webwork.util.Encoding;
+import webwork.util.URLCodec;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
@@ -21,7 +22,6 @@
import java.io.IOException;
import java.io.PrintWriter;
import java.io.OutputStreamWriter;
-import java.net.URLEncoder;
import java.util.*;
import org.apache.commons.logging.LogFactory;
@@ -59,7 +59,7 @@
rd.include(aContext.getRequest(), pageResponse);
//write the response back to the JspWriter, using the correct encoding.
- String encoding = getEncoding();
+ String encoding = Encoding.getEncoding();
if (encoding != null)
{
//use the encoding specified in the property file
@@ -72,43 +72,6 @@
}
}
- private static String encoding;
- private static boolean encodingDefined = true;
-
- /**
- * Get the encoding specified by the property 'webwork.i18n.encoding' in webwork.properties,
- * or return the default platform encoding if not specified.
- * <p>
- * Note that if the property is not initially defined, this will return the system default,
- * even if the property is later defined. This is mainly for performance reasons. Undefined
- * properties throw exceptions, which are a costly operation.
- * <p>
- * If the property is initially defined, it is read every time, until is is undefined, and then
- * the system default is used.
- * <p>
- * Why not cache it completely? Some applications will wish to be able to dynamically set the
- * encoding at runtime.
- *
- * @return The encoding to be used.
- */
- private static String getEncoding()
- {
- if (encodingDefined)
- {
- try
- {
- encoding = Configuration.getString("webwork.i18n.encoding");
- }
- catch (IllegalArgumentException e)
- {
- encoding = System.getProperty("file.encoding");
- encodingDefined = false;
- }
- }
- return encoding;
-
- }
-
public static String getContextRelativePath(ServletRequest request,
String relativePath)
{
@@ -248,7 +211,7 @@
urlBuf.append(concat);
urlBuf.append(name);
urlBuf.append('=');
- urlBuf.append(URLEncoder.encode(values.get(i).toString()));
+ urlBuf.append(URLCodec.encode(values.get(i).toString()));
concat = "&";
}
}
Index: URLTag.java
===================================================================
RCS file: /cvsroot/opensymphony/webwork/src/main/webwork/view/taglib/URLTag.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- URLTag.java 19 Jun 2005 23:21:24 -0000 1.26
+++ URLTag.java 16 May 2006 07:34:08 -0000 1.27
@@ -12,12 +12,12 @@
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import java.io.IOException;
-import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import webwork.util.BeanUtil;
+import webwork.util.URLCodec;
/**
* This tag is used to create a URL.
@@ -37,8 +37,8 @@
protected String value;
protected String includeParamsAttr;
protected Map params;
- protected boolean includeContext = true;
- protected boolean encodeResult = true;
+ protected boolean includeContext = true;
+ protected boolean encodeResult = true;
// Public --------------------------------------------------------
/**
@@ -69,13 +69,13 @@
includeParamsAttr = aName;
}
- public void setEncode(boolean encode) {
- encodeResult = encode;
- }
+ public void setEncode(boolean encode) {
+ encodeResult = encode;
+ }
- public void setIncludeContext(boolean includeContext) {
- this.includeContext = includeContext;
- }
+ public void setIncludeContext(boolean includeContext) {
+ this.includeContext = includeContext;
+ }
public void addParameter(String name, Object value) {
if (params == null)
@@ -184,7 +184,7 @@
if (value instanceof String) {
link.append(name);
link.append('=');
- link.append(URLEncoder.encode((String) value));
+ link.append(URLCodec.encode((String) value));
} else {
String[] values = (String[]) value;
@@ -194,7 +194,7 @@
String multiValue = values[i];
link.append(name);
link.append('=');
- link.append(URLEncoder.encode(multiValue));
+ link.append(URLCodec.encode(multiValue));
if (i != values.length -1)
link.append("&");
}
@@ -225,7 +225,7 @@
pageContext.getOut().write(result);
} catch (IOException _ioe) {
throw new JspException("IOError: " + _ioe.getMessage(), _ioe);
- }
+ }
}
super.doEndTag();
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642