Basically, we want to create a taglib that can possibly forward request execution to another page, similar to <jsp:forward />
. How can we prevent the rest of the JSP page from executing from within the taglib?
views:
81answers:
2
A:
If you don't want to continue processing the original page after passing control to another you are better off using a redirect rather than a forward.
response.sendRedirect("foo.jsp");
This will redirect to the new page and stop processing the old one.
However - redirects are only usable if you have not written anything to the response body yet (i.e. not sent any data back to the client).
Chris Harcourt
2009-12-14 10:09:02
A:
You shouldn't be doing this in a taglib. Rather do it in a Servlet or Filter, before any bit is been sent to the response. Otherwise you will possible get into IllegalStateException: resposne already committed
troubles.
BalusC
2009-12-14 11:05:23