Bear Bibeault wrote:Think about it for a minute. What issues the redirect? The server? The browser? Other?
Ummm.. a redirect is issued by the server to the browser? (redirecting to xyz Url)
According to the API, the server would convert the relative URL to absolute URL before sending the redirect back to the browser. So "/test/index.html" would become "http://www.example.com/myapp/test/index.html" . So still not sure why the browser would not find it?
Step 1. Client (browser) sends a request to resource X
Step 2. Resource X starts processing the request in a servlet and comes across response.sendDirect("resource Y").
Step 3. Resource X sends back a response to the client with a status code + some info, saying "go to resource Y"
Step 4. Client sends a new request to resource Y
/test/index.html would get converted to http://www.example.com/test/index.html (not with the app-directory in between as I wrote previously)
Does it have something to do with the 'servlet container root' instead of 'application root'?
I think whatever Pedro said is correct.
the response.sendRedirect() method expects its path parameter to be relative to the server root, not the webapp root. Thus, to send a redirect to the above URL from a servlet running , you must say
During a redirect the server sends headers to the browsers, which in turn, issues the new request. All requests from the browser need to include the context path, otherwise the container would have no idea what application to contact.