Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Stanimir Stamenkov Newsgroups: comp.lang.java.programmer Subject: Re: [LONG] java.net.URI encoding weirdness Date: Tue, 06 May 2014 11:02:25 +0300 Organization: A noiseless patient Spider Lines: 21 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Tue, 6 May 2014 08:02:25 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="9f3b1682542d0f283a9d005dcd9bed05"; logging-data="949"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18cmCwNB6pHG2lMPdXE8ZRx" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0 SeaMonkey/2.26 In-Reply-To: X-Face: "@)%Vlap6d%OVYDS}B4YUWE@yUy+^!w/+.q.,c5kjI#+uG?kYP&r/pTjNWgo:g[A,O=AL3/ j&4Le2cau$ useless. Since the query string must be submitted as a unit, it must > already be using & and =, and any special characters in it that are > to be taken literally must already be encoded, yet the constructor > treats it as unencoded, and adds another level of encoding. That > also goes for your userInfo component with an @ in it to separate > user and domain. > > I think the solution for me was just to use URLEncoder, concatenate > the strings, then pass to URI.create(). Yeah, that was what I was trying to avoid – the manual URI construction/concatenation, and then the overhead of parsing (for every construction). This appears the most natural usage of the URI constructors to me – having the different components/properties already parsed. -- Stanimir