java - What's the difference between encodeURL and encodeRedirectURL? -
i've seen existing question: difference between encodeurl
, encoderedirecturl
. doesn't answer question really. in testing, these 2 methods same. whatever use print
or sendredirect
, both work fine.
so there difference? want see source code maybe can find difference, httpservletresponse
interface no implementation. implementation code?
but
httpservletresponse
interface no implementation. implementation code?
it's servletcontainer concrete servlet api implementation. in case of example apache tomcat concrete implementation org.apache.catalina.connector.response
. here extracts of relevance:
1128 /** 1129 * encode session identifier associated response 1130 * specified redirect url, if necessary. 1131 * 1132 * @param url url encoded 1133 */ 1134 public string encoderedirecturl(string url) { 1135 1136 if (isencodeable(toabsolute(url))) { 1137 return (toencoded(url, request.getsessioninternal().getidinternal())); 1138 } else { 1139 return (url); 1140 } 1141 1142 }
1159 /** 1160 * encode session identifier associated response 1161 * specified url, if necessary. 1162 * 1163 * @param url url encoded 1164 */ 1165 public string encodeurl(string url) { 1166 1167 string absolute = toabsolute(url); 1168 if (isencodeable(absolute)) { 1169 // w3c spec said 1170 if (url.equalsignorecase("")){ 1171 url = absolute; 1172 } 1173 return (toencoded(url, request.getsessioninternal().getidinternal())); 1174 } else { 1175 return (url); 1176 } 1177 1178 }
the difference subtle. encodeurl()
uses full absolute url whenever given (relative) url empty.
Comments
Post a Comment