Jump to Navigation

Java

Code URI Component

Java Duke

JavaScript has a handy function built in called encodeURIComponent, and the corresponding function decodeURIComponent.

These functions allow you effectively strip out parts of a string that could cause problems when sent in a URI, in a get request for example.

I also recently found it handy for encoding strings for sending to and from a JSP server over AJAX, the trouble came up when I realised that there is no built in equivalent functions server side. A quick search of the net revealed a few solutions, but none that actually worked, not in Java, or PHP, or anything else that I could have adapted. A bit surprised by this lack of a solution to a common problem, I investigated what these functions do.

Syndicate content