JDK-6794192 : Need a way to quote URI parameter values
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 6u10
  • Priority: P5
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2009-01-15
  • Updated: 2013-09-13
  • Resolved: 2010-06-29
Related Reports
Duplicate :  
Description
A DESCRIPTION OF THE REQUEST :
The URI constructors enable one to build a URI from components and quote them as necessary. Unfortunately, there doesn't seem to be a way to build the query string. The URI class doesn't account for the fact that query parameter values might contain characters that must be quoted on a per-parameter basis. The constructor takes a single string for multiple query arguments which makes it technically impossible for it to quote values as necessary.

We need a method that takes in a raw parameter value and and returns the quoted representation. This method should work for both query parameters and matrix URIs: http://www.w3.org/DesignIssues/MatrixURIs.html

  To make matters worse, there aren't even any 3rd-party libraries to do this. It seems everyone tries rolling their own RFC2396 implementation.

I've discovered that https://jsr311.dev.java.net/nonav/javadoc/javax/ws/rs/core/UriBuilder.html 
does what I'm asking for. In fact, it is pretty much the only implementation I found that does this (I couldn't find any other 3rd-party libraries).

I'm happy I found a workaround but I'd still recommend that some of this functionality (minus any REST-specific stuff) should be folded back into Uri if possible.

JUSTIFICATION :
Impossible to build URI parameters that need to be escaped

Comments
EVALUATION It looks like the functionality request by this RFE should be provided as part of 6306820.
29-06-2010