O'Reilly logo

Head First Servlets and JSP, 2nd Edition by Bert Bates, Bryan Basham, Kathy Sierra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Redirect vs. Request Dispatch

image with no caption

When a servlet does a redirect, it’s like asking the client to call someone else instead. In this case, the client is the browser, not the user. The browser makes the new call on the user’s behalf, after the originally-requested servlet says, “Sorry, call this guy instead...”

The user sees the new URL in the browser.

image with no caption

When a servlet does a request dispatch, it’s like asking a co-worker to take over working with a client.

The co-worker ends up responding to the client, but the client doesn’t care as long as someone responds.

The user never knows someone else took over, because the URL in the browser bar doesn’t change.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required