I am trying to use the encodeURL
method in a jsp to encode a URL with "%" symbol.
response.encodeURL(/page1/page2/view.jsp?name=Population of 91% in this place)
Whenever the button is clicked, "The website cannot display the page"
error is shown.
But when you manually change the "%"
symbol to "%25"
like this "Population of 91%25 in this place
",then the correct page is displayed.
Also whenever the "%"
symbol is placed at last like this "In this place Population of 91%
", then the page is correctly displayed but i noticed that in the address bar its still shown as "%"
and not as "%25"
and still its working.
When I searched around, its mentioned only to use the other methods like encodeURI() & encodeURIComponent().
Can you suggest me a solution while still using the encodeURL
method to display the pages correctly even if there is a "%"
symbol. Should i use replace()
or why isnt the encodeURL()
method working correctly?