I am trying some snippets for preparing myself for SCWCD. While studying encodeURL() and encodeRedirectURL(), I found that using any of these does not make any difference if you are going to redirect the request to say some other jsp page or servlet. Below is the code snippet i tried:
The main difference is:
posted 10 years ago
Yes perfectly said however i was trying to figure out situations in which one has to use specific method. I am reading SCWCD by Charles Lyons, it mentions that for sendRedirect() one has to use encodeRedirectURL() whereas when one wants to use hyperlinks on page then use encodeURL(). Also it mentions that sometimes (not always) the output of both these methods differ, so I wanted to understand when that happens. Thats why out of curiosity, I tried to use encodeURL() in combination with sendRedirect() and it works just same as with encodeRedirectURL(). I am definitely missing on something, but dont know what
The API doesn't tell us what these methods do differently. Only that you are supposed to use the one when using redirect, and the other in other cases.
What's going on behind the scenes we're not supposed to care about.