0

What is the correct way in jsp to retrieve a integer parameter from an url? I need to make sure it's an integer to avoid possible XSS issues, as it's directly inserted in a Spring message i18n and sent to the client.

I need to retrieve 5 from the url http://localhost?allowed_phones=5. I've tried this, which does not work:

<spring:message code="code" arguments="{Integer.valueOf(param['allowed_phones'])}" />

What could be the cause?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
BobJI
  • 163
  • 1
  • 9
  • you got an opening brace `{` but no closing brace`}` – jhamon Mar 11 '20 at 16:42
  • 1
    Does this answer your question? [How to get parameters from the URL with JSP](https://stackoverflow.com/questions/1890438/how-to-get-parameters-from-the-url-with-jsp) – jhamon Mar 11 '20 at 16:43
  • I'm sorry this was a typo in my question, not in my actual code. It's fixed. – BobJI Mar 11 '20 at 16:44
  • No my main question is basically how to convert the param to an integer. – BobJI Mar 11 '20 at 16:44
  • @jhamon I've edited my question (and its title) to emphasize that the question is actually about the conversion from String to Integer in JSP. – BobJI Mar 11 '20 at 16:50

0 Answers0