You need to
decide at the top of the page
before anything is started to be printed whether to redirect.
However, I believe that just like with tag classes , with JSP scriptlet or JSTL you can cancel page processing, then redirect, but that may be the same clause(meaning you could have processed a large portion of the page but not sent it).
Look through the <@page > directives for buffer , and
i think one directive has an attribute output whether to be "verbose"(output as it occurs) also.
If you need to do that after print, you could cease at an appropriate element and print a javascript with
<script>
window.location="
http://mysite/thepage.jsp";
</script>