I will try my best to explain let me know whether you get it.
As per Head First URL re-writing is automatic ONLY if you encode your URL's through the 2 method of response object i.e 1. encodeURL(java.lang.String url) and 2. encodeRedirectURL(java.lang.String url)
rest of the things container will take care by itself. NOW the question is when to use which method??
All URLs sent to the HttpServletResponse.sendRedirect method should be run through encodeRedirectURL(java.lang.String url)
Next Doubt may come like what is sendRedirect so from the Java API here is the extract.
sendRedirect public void sendRedirect(java.lang.String location) throws java.io.IOExceptionSends a temporary redirect response to the client using the specified redirect location URL. This method can accept relative URLs; the servlet container must convert the relative URL to an absolute URL before sending the response to the client. If the location is relative without a leading '/' the container interprets it as relative to the current request URI. If the location is relative with a leading '/' the container interprets it as relative to the servlet container root. If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.
So the final conclusion is YOU CANNOT USE response.encodeRedirectURL(response.redirect("url")); what you mentioned in the question!!!
Siddharth Purandare<br />SCJP 1.4 - 76%<br />SCWCD 1.4 - 85%<br /> <br />It is the "attitude" and not the "aptitude" which determines "altitude".
Joined: Feb 07, 2005
HFS&JSP pno-237 says URL rewriting is automatic but only if you encode your URLs.You have to run all your URLs through a method ot the response object-encodeURL() or encodeRedirectURL()and the container does everything else. I thing meaning of above statement is