The <jsp:forward> standard action

You CAN forward from one JSP to another. Or from one JSP to a servlet. Or from one JSP to any other resource in your web app.

Of course, you don’t usually want to do this in production, because if you’re using MVC, the View is supposed to be the View! And the View has no business doing control logic. In other words, it shouldn’t be the View’s job to figure out if the guy is logged in or not—someone else should have made that decision (the Controller), before deciding to forward to the View.

image with no caption

But let’s suspend all that good MVC judgement for the time being, and see how we could do it, if we were to forward from a JSP page to something else.

Why bother if you’ll never do it? Well, you might one day stumble on a problem where <jsp:forward> is a useful solution. More importantly, like a lot of what’s in the book (and the exam), the use of <jsp:forward> is outthere. Lurking in gazillions of JSPs that you might one day find yourself maintaining (or ideally refactoring).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset