0

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.

sergionni
  • 13,290
  • 42
  • 132
  • 189

2 Answers2

1

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

gustafc
  • 28,465
  • 7
  • 73
  • 99
  • This link i've got as external feed link. Could i influence on its encoding? – sergionni Sep 21 '09 at 14:13
  • in jsp it look like: i mean that sub.htmlLink value is external feed url. – sergionni Sep 21 '09 at 14:17
  • You'd think JSTL had a built-in function for this, but it doesn't. Googling turns up this, which may or may not be useful to you: http://marc.info/?l=taglibs-user&m=114127478601259&w=2 – gustafc Sep 21 '09 at 15:41
  • gustafc, thank you for good hint. Initially, i tried do it on frontend, like: But this solution is not very graceful,so issue was resolved on backend ,using URL and URLEncoder classes.So for now i get parameter in request that doesn't cut # symbol. – sergionni Sep 22 '09 at 12:23
1

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
  • 16,034
  • 7
  • 51
  • 41
  • Yes,you're correct manually parsing is not so cute. Thanks for help.I've done it with URLEncoder on backend. – sergionni Sep 22 '09 at 12:24