Re: @URLMapping path values gets URL encoded in form's 'action' attribute

Splash Forums PrettyFaces Users @URLMapping path values gets URL encoded in form's 'action' attribute Re: @URLMapping path values gets URL encoded in form's 'action' attribute

#20236

Vidar
Participant

Thanks for the quick replies.

I’m running on Glassfish3 and couldn’t not find any updated Glassfish info for this after trying the above tomcat setting and similar suggestions without it having any effect.

My, anything but pretty, workaround involves manually URL encoding the “path”-string in the get-method and in the setter do a double URL decode to get the original value back.

At least its working and no security setting has been disabled.

My getter and setter that PrettyFaces injects the page path into now looks like

public void setPath(String pagePath) {
try {
// at this point any "/"-char looks like "%252F"
pagePath = URLDecoder.decode(pagePath, "UTF-8"); // now the "/" looks like "%2F"
pagePath = URLDecoder.decode(pagePath, "UTF-8"); // and we are back at "/"
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
this.pagePath = pagePath;
}

public String getPath() {
try {
return URLEncoder.encode(pagePath, "UTF-8"); // encodes the "/" into "%2F"
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return pagePath;
}

the action attribute of a form now looks like

<form enctype="application/x-www-form-urlencoded" action="/application/category%252Fsubcategory/?page=1" method="post" name="list:j_idt121" id="list:j_idt121">
...
</form>

“/” has now been encoded into “%252F” instead of “%2F”, and the URL is no longer causing any trouble reaching the web app.