views:

276

answers:

2

One of parameters for action link looks like:

itemUrl=feedLink.html#xtor=RSS-3208

when I execute next code in backend in processAction():

String itemUrl = (String) request.getParameter("itemUrl");

,that I get next value: feedLink.html

e.g. request cuts itemUrl value after # symbol

escapeXml="true" in .jsp file doesn't help.

+1  A: 

You have to URI encode the parameter names and values - your link should be itemUrl=feedLink.html%23xtor=RSS-3208.

gustafc
This link i've got as external feed link. Could i influence on its encoding?
sergionni
in jsp it look like: <c:set var="extractUrl"> <portlet:actionURL portletMode='view'> <portlet:param name='itemUrl' value='${sub.htmlLink}'/> </portlet:actionURL> </c:set> i mean that sub.htmlLink value is external feed url.
sergionni
gustafc
gustafc, thank you for good hint.Initially, i tried do it on frontend, like:<c:set var="ur" value="${fn:replace(ur,'#','%23')}"></c:set>But this solution is not very graceful,soissue was resolved on backend ,using URL and URLEncoder classes.So for now i get parameter in request that doesn't cut # symbol.
sergionni
+1  A: 

Anything after the # in an URL specifies the location on the page the browser should display; it's not part of the URL itself. As such, if you want an actual # in your URL, it needs to be escaped (if the parser is actually compliant).

In theory, you could parse the whole URL being sent to you manually, but the better solution is to get the caller of your page to send you a correct URL in the first place (well, a URL that represents what they want, since the one in question is valid, per se).

RHSeeger
Yes,you're correct manually parsing is not so cute.Thanks for help.I've done it with URLEncoder on backend.
sergionni