SkipPageException: stops processing the page...

Imagine you’re in a page that invokes the tag, and the tag depends on specific request attributes (that it gets from the JspContext available to the tag handler).

Now imagine the tag can’t find the attributes it needs, and that the tag knows the rest of the page will never work if the tag can’t succeed. What do you do? You could have the tag throw a JspException, and that would kill the page... but what if it’s only the rest of the page that won’t work? In other words, what if you still want the first part of the page—the part of the page that’s evaluated before the tag invocation—to still appear as the response, but you don’t want the response to include anything still left to be processed after the tag throws an exception?

No problem. That’s exactly why SkipPageException exists.

The tag handler doTag() method

image with no caption

The JSP that invokes the tag

image with no caption

Get Head First Servlets and JSP, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.