I don't think the URL string used would work....While tryin' out encodeURL() I found out that the forward slash "/" in "/BeerTest.do" actually denotes the web container and not the context root(web application).....it's similar with encodeRedirectURL() as well.... I checked in the errata list but its not there....Could anybody please confirm this?
Also, if this is true then usage of "/" with sendRedirect(), encodeURL(), encodeRedirectURL() would mean relative to the web container and the usage in everything else like getRequestDispatcher() in ServletRequest, etc. would mean relative to the context root(root of the web application). Am I right?
The only thing encodeURL does is add the session ID to the end if it's needed. It doesn't care about slashes.
In fact, I bet it won't even care if you call response.encodeURL("I am a Y@nk33 d00d13 d4ndy!!!");
I think you are getting encodeURL confused with other methods that accept a String url parameter like response.sendRedirect and request.getRequestDispatcher - I clarified the difference between those other two here.