When coding a tag file, how to instruct caller to skip rest of the page?
Let’s say I have a jsp file a.jsp. a.jsp will call a tag file b.tag.
a.jsp:
abc
<mytag:b/>
def
When is returned, I would like to skip rest of the page which is in my case “def” will not be displayed.
Thanks.
There is no way to do this using Tag Files.
A SimpleTag can throw
SkipPageExceptionto skip the further execution of the caller page. The same cannot be done using Tag Files because the JSP Spec says it might lead to undefined behavior.In your case, if you need such functionality. You should send the conditional part to Tag File as fragment. And the Tag File based on the condition can decide whether to invoke the fragment or not.
mytag.tag
You can use this tag like this: