My understanding about encodeURL is that, if the cookies are not enabled, then the container creates the session id and passes it along with response and similarily gets the sessionId through the request that the client sends.
encodeRedirectURL is used when I redirect to another servlet (again cookies are not enabled), and that servlet makes use of this session Id ?
My question is: why dont we have a similar method for encodeDispatchURL - so that the servlet to which the request is dispatched can make use of the sessionId.
posted 11 years ago
Because dispatch action is performed at server side.And during dispatch we are passing the request and response object.
Since the same request and response object available in the forwarded or included servlet/jsp, we don't need to encode it.