This is a small jsp page :
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page errorPage="errorpage.jsp" %>
<html tags>
<%-- about to be bad ! --%>
<% int x = 10/0; %>
</html tags>
The above page receives request from a servlet named FooServlet.(whose job is only to call the above jsp page). As soon as the servlet starts i see the default error page with it’s message. But the url in the browser is same as that of the servlet. Why is it so ? Like the url of the error page is still http://localhost:8080/WebTesters/FooServlet.
Because this is part of the specification of how request forwarding works. A forward routes the request to the alternate resource via the server, which acts as a proxy between the client and the alternate resource.
This is different from a redirect, where the URL of the alternate resource is sent to the client as a header field, and the client is responsible for making a followup call to retrieve the alternate resource.