encodeURL is used with RequestDispatcher when you want to keep track of session so the jsessionid is added to your url.
A RequestDispatcher is used to either forward the request to a resource or include the contents of another resource. Irrespective of that, it is a server side paradigm.
encodeURL() as has already been pointed out twice has not got nothing to do with RequestDispatchers. It is used in jsps and/or Servlets only when constructing a url (a link, a form post url etc).
ram.