On 24 March 2014 23:01, Christopher BROWN <[email protected]> wrote: > Hello, > > This article: > http://blog.lunatech.com/2009/02/03/what-every-web-developer-must-know-about-url-encoding > > ...refers to the pitfalls of using Java's standard URLEncoder / URLDecoder > classes for anything other than *form* encoding. In particular, it is > unsuitable for path segments, and has no concept of matrix parameters (such > as ;jsessionid=xxx but appearing in any segment). The standard URI class > in the JDK doesn't appear to provide much in the way of solutions either. > > Given that when encoding and decoding URLs/URIs, I can first split into > segments (easy enough splitting on "/"), does anyone on this HTTP client > list have any recommendations for correctly encoding and decoding each > individual path segment (and extracting matrix parameters)? After > searching, I've found no standalone class (read: without being bloated or > loaded with dependencies) that can both encode and decode. Given how many > implementors seem to have got it more or less wrong, I'm humble enough not > to try it myself unless there really is no other choice.
The java.net.URI class is worth a careful review. It has constructors that encode parameters and a constructor that decodes its parameter. > Thanks, > Christopher --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
