It's got nothing to do with encodeURL/encodeRedirectURL (which are used for handling URL rewriting in the presence of HTTP sessions) or a missing port (which would lead to an error like "can't find host").
The "#" character separates the URL parameters from the fragment (which in this case is "5"). If the "#" is actually part of the parameter, then the URL needs to be encoded by the java.net.URLEncoder.encode method. Afterwards it will look like "http://localhost/host/page.do?abc=%235", which means the "#" has been replaced by its hexadecimal equivalent, and is no longer interpreted as a special URL character. [ March 15, 2007: Message edited by: Ulf Dittmer ]