1

JS fiddle created at https://jsfiddle.net/ankitwasankar/sc50ecyf/ demonstrates, how the url sent as a parameter decode itself inside function. Is it the expected behaviour. Do I need to encode url passed as parameter again inside function. Currently when URL is opened with window.location.href it doesn't contain %26 instead contains &. So on server, HttpServletRequest.getParameterNames() returns two parameters instead of one.

1 Answer 1

1

What about split %26 in-between, like:

<a href='javascript:print_me("https://www.google.co.in/search?query=a%2" + "6b=26")'>Click</a>

This prevents the auto-decoding, although it's a little bit hacky.

Sign up to request clarification or add additional context in comments.

1 Comment

It worked for me, thanks. Also double encoding the URL parameters solved the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.