Discussions

Web tier: servlets, JSP, Web frameworks: How to terminate a JSP pages script?

  1. How to terminate a JSP pages script? (2 messages)

    Hello there,

    Is it possible to stop a JSP page script running at any point of time. As in ASP, the Request object provides End() method, which will stop the ASP script execution and flush all the output to the client. Rest of the script after Response.End() statement will be ignored and will not be processed.

    Is there any method available with JSP page, through which we can implement the above mentioned functionality. If not then what is the work-around?

    Is it possible to use return statement? Is return statemet recommended within a JSP page?

    Jay
  2. Using the return statement will terminate your JSP, and is acceptable practice.

    Throwing an uncaught exception will work to, but that will send you to an error page.
  3. You can use a taglib returning Tag.SKIP_PAGE in the method doEndTag.