0

I am working on a Java web application. This application receives URL parameters from 3rd party's app. Therefore, value of the URL parameter may not be encoded. How do I parse the URL parameter value when parameter value contains unencoded '&' (encode value %26)?

For example: "page.jsp?title=Street & Smith&address=1223"

Here, 3rd party passed unencoded parameter value: 'Street & Smith'

Thanks M.F.H

MFH
  • 357
  • 3
  • 17

2 Answers2

1

you can't, that's a broken URL (which is why encoding exists in the first place).

you could write some heuristics to "guess" as the the original intent, but it will be a guess (and will be wrong sometimes).

jtahlborn
  • 52,909
  • 5
  • 76
  • 118
0

Here's another Stackoverflow post from a User who was looking to accomplish similar encoding of parameter values as you are attempting to do: How do I encode URI parameter values?

Community
  • 1
  • 1
Philip Tenn
  • 6,003
  • 8
  • 48
  • 85