[JAVASERVERFACES_SPEC_PUBLIC-1019] h:outputLink etc strange URL encoding Created: 16/Jun/11  Updated: 01/Aug/14  Resolved: 17/Jun/11

Status: Closed
Project: javaserverfaces-spec-public
Component/s: Components/Renderers
Affects Version/s: 2.1
Fix Version/s: 2.2

Type: New Feature Priority: Major
Reporter: ejp Assignee: Ed Burns
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: 0 minutes
Time Spent: 1 hour, 13 minutes
Original Estimate: Not Specified


Attachments: Text File 20110617_i_spec_1019.patch    
Issue Links:
depends on JAVASERVERFACES_SPEC_PUBLIC-479 UIData should support the collection ... Closed


If I have an h:outputLink with a value containing spaces, it is rendered with the spaces converted to +.

It seems to me that if it is going to convert this at all, it should do so correctly, i.e. to %20. Alternatively it should leave it alone and let it fail as originally supplied.

Am I missing something here?

I have a legacy content database where the document index provides URLs contain spaces. I can change that, and probably will, but maybe this is a bug and will get fixed the way I would like?

Discussion <a href="http://forums.oracle.com/forums/thread.jspa?messageID=9639501&#9639501">here</a>. Appears to involve use of URLEncoder for the one thing it cannot do, which is encode a URL. Should be using URI.toASCIIString().

Comment by Ed Burns [ 17/Jun/11 ]

You are correct in filing this as a spec issue, because the problem stems from the specification for the renderer for javax.faces.Output javax.faces.Link.


The entire "href" string must be passed through a call to the encodeResourceURL() method of the ExternalContext.

Which ends up calling: javax.servlet.http.HttpServletResponse method encodeURL(url).

Comment by Ed Burns [ 17/Jun/11 ]


Comment by Ed Burns [ 17/Jun/11 ]

Sending jsf-api/doc/standard-html-renderkit-base.xml
Sending jsf-api/doc/standard-html-renderkit.xml
Sending jsf-api/src/main/java/javax/faces/context/ResponseWriter.java
Sending jsf-ri/src/main/java/com/sun/faces/util/HtmlUtils.java
Sending jsf-ri/systest/build-tests.xml
Adding jsf-ri/systest/web/render/outputLinkSpaces.jsp
Sending jsf-tools/src/main/resources/com/sun/faces/generate/facesdoc/stylesheet.css
Transmitting file data .......
Committed revision 9175.

Comment by ejp [ 17/Jun/11 ]

As a workaround until this fix is released, you can add the following converter to the h:outputLink element:

public class URLConverter implements Converter
public Object getAsObject(FacesContext fc, UIComponent uic, String string)

{ return string; }

public String getAsString(FacesContext fc, UIComponent uic, Object object)
String path = object.toString();

{ if (path.indexOf(' ') >= 0) path = new URI(null, path, null).toASCIIString(); }

catch (URISyntaxException exc)

{ // logger.log(Level.SEVERE, "uri="+path, exc); }

return path;

Comment by ejp [ 03/Dec/12 ]

The same problem also turns up in h:graphicImage. For example:

h:graphicImage value="{{lab.path}}VisualObjective.jpg" where lab.path evaluates to /cLabsTest/EDSILabs/vLearning/Cisco Courses/Enterprise (Routers & Switches)/Interconnecting Cisco Network Devices 1/ICND1 Lab 2-2 Performing Switch Startup and Initial Configuration/VisualObjective.jpg


img src="/cLabsTest/EDSILabs/vLearning/Cisco+Courses/Enterprise+(Routers+&+Switches)/Interconnecting+Cisco+Network+Devices+1/ICND1+Lab+2-2+Performing+Switch+Startup+and+Initial+Configuration/VisualObjective.jpg"

Should I report this as a new bug?

Comment by Manfred Riem [ 01/Aug/14 ]

Closing resolved issue out

Generated at Mon Oct 05 23:37:53 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.