You are fully aware that URLEncoder.encode(String, String) exists only under JDK 1.4, are you? (Also, URLEncoder.encode(String) is only deprecated from there upwards...)
If you want your code to have charset-sensitive URL encoding and still remain compatible with JDK < 1.4, you need to use a hack like URLEncoder.encode(new String(url.getBytes(encoding))) Naturally, this approach is fragile in case your platform default encoding is something exotic, altough it works fine with ISO-8859-x encodings being default encodings for the platform. Attila ----- Original Message ----- From: <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, March 25, 2003 12:38 AM Subject: DO NOT REPLY [Bug 18301] New: - Fixed deprecation warning for URLEncoder.encode(String) method. > DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG > RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT > <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18301>. > ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND > INSERTED IN THE BUG DATABASE. > > http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18301 > > Fixed deprecation warning for URLEncoder.encode(String) method. > > Summary: Fixed deprecation warning for URLEncoder.encode(String) > method. > Product: Velocity > Version: 1.3.1-rc2 > Platform: Other > OS/Version: Other > Status: NEW > Severity: Normal > Priority: Other > Component: Source > AssignedTo: [EMAIL PROTECTED] > ReportedBy: [EMAIL PROTECTED] > > > D:\java\jakarta-velocity- > tools\src\java\org\apache\velocity\tools\view\tools>cvs > diff -u -r1.3 LinkTool.java > Index: LinkTool.java > =================================================================== > RCS file: /home/cvspublic/jakarta-velocity- > tools/src/java/org/apache/velocity/to > ols/view/tools/LinkTool.java,v > retrieving revision 1.3 > diff -u -r1.3 LinkTool.java > --- LinkTool.java 22 Mar 2003 20:33:09 -0000 1.3 > +++ LinkTool.java 24 Mar 2003 23:33:01 -0000 > @@ -57,6 +57,7 @@ > > import java.net.URLEncoder; > import java.util.ArrayList; > +import java.io.UnsupportedEncodingException; > > import javax.servlet.http.HttpServletRequest; > import javax.servlet.http.HttpServletResponse; > @@ -474,9 +475,14 @@ > public String toString() > { > StringBuffer out = new StringBuffer(); > - out.append(URLEncoder.encode(key)); > - out.append('='); > - out.append(URLEncoder.encode(String.valueOf(value))); > + String encoding = response.getCharacterEncoding(); > + try { > + out.append(URLEncoder.encode(key, encoding)); > + out.append('='); > + out.append(URLEncoder.encode(String.valueOf(value),encoding)); > + } catch (UnsupportedEncodingException e) { > + out.append("UnsupportedEncoding " + e.getMessage()); > + } > return out.toString(); > } > } > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
