JSTLのParamSupport.javaより。
//*********************************************************************
// Constructor and initialization
// URLEncoder.encode(String) has been deprecated in J2SE 1.4.
// Take advantage of the new method URLEncoder.encode(String, enc)
// if J2SE 1.4 is used.
static {
try {
Class urlEncoderClass = Class.forName("java.net.URLEncoder");
encodeMethod1_4 =
urlEncoderClass.getMethod(
"encode",
new Class {String.class, String.class});
} catch (Exception ex) {} // encodeMethod1_4 will be null if exception
}
・・・
if (encodeMethod1_4 != null) {
Object methodArgsName = new Object[2];
methodArgsName[0] = name;
methodArgsName[1] = pageContext.getResponse().getCharacterEncoding();
Object[] methodArgsValue = new Object[2];
methodArgsValue[0] = value;
methodArgsValue[1] = pageContext.getResponse().getCharacterEncoding();
try {
parent.addParameter(
(String)encodeMethod1_4.invoke(null, methodArgsName),
(String)encodeMethod1_4.invoke(null, methodArgsValue));
} catch (Exception ex) {
throw new JspException("System error invoking URLEncoder.encode() by reflection.", ex);
}
} else {
// must use J2SE 1.3 version
parent.addParameter(
URLEncoder.encode(name), URLEncoder.encode(value));
}