<str:encodeUrl>desayuño</str:encodeUrl> should return desayu%F1o. Instead it returns desayu%3Fo which is desayu?o. All accents are converted to ?.
Steve, <str:encodeUrl> calls java.net.EncodeURL.encode(text) to encode the text. The solution for your problem would be calling java.net.EncodeURL.encode(text,encoding), but that method is only available on J2SE 1.4. We could add an attribute encoding for this tag and check the J2SE version at runtime: public String changeString(String text) throws JspException { String result = null; if ( this.encoding != null ) { try { result = URLEncoder.encode( text, this.encoding ); } catch( NoSuchMethodError exc ) { System.err.println( "WARNING: attribute encoding on tag encodeUrl should be used only in a " + "J2SE 1.4 compatible web container. Using default container."); } catch( UnsupportedEncodingException exc2 ) { System.err.println( "WARNING: unsupported encoding used on tag encodeUrl: " + this.encoding ); } } if ( result == null ) { result = URLEncoder.encode(text); } return result; } So, Hen, what do you think about it? If you give me an ok, I will commit these changes on CVS. Otherwise, we should mark it as WON'T FIX. Felipe
Sounds good to me. Feel free to go ahead with the change.
I committed the changes on CVS, but I won't mark it as fixed yet as I couldn't test it - my Linux setup is still messing with encoding. I'm pretty sure the code is fine because the same code worked standalone (i.e., outside Tomcat). Anyway, I'll be attaching a test case.
Created attachment 10756 [details] Test case (JSP page)
I rolled back the changes because it broke the build: in order to fix it, the whole project should be compiled against J2SE 1.4, which is not a good idea. Anyway, I'm attaching my changes as a patch.
Created attachment 10772 [details] Zip file with the changed files