Ns adp abort

From AOLserver Wiki
Jump to: navigation, search

Man page: http://aolserver.com/docs/tcl/ns_adp_abort.html


ns_adp_abort - Stop processing of the current ADP and discard queued output


ns_adp_abort ?retval?


This command stops processing of the current ADP by throwing a Tcl error along with an "ADP exception" of ADP_ABORT. This has the side-effect of truncating the current ADP's output buffer so that no queued output for the current ADP is sent to the client.
However, if a streaming script was processed before ns_adp_abort was called, the data will already have been output. Also, if any commands that cause output, such as ns_return or ns_write for example, were called before ns_adp_abort, then their output will already have been output also.
The optional retval becomes the return value of the ADP if specified, otherwise an empty string is returned.


   # The ns_adp_abort after ns_returnredirect ensures no further ADP
   # processing happens except the redirect itself.
   ns_returnredirect http://aolserver.com/


Because it's possible to catch the ns_adp_abort exception, it is possible for code to execute after an ns_adp_abort in the current adp block. However, all subsequent adp blocks are guaranteed to not get evaluated. For example:
    catch { ... some code that executes ns_adp_abort  }
    if {[ns_adp_exception] eq "abort"} {
        ... some cleanup code
   <% ... this next block will NOT be evaluated even though ns_adp_abort is caught in the prior block %>


ns_adp_append, ns_adp_argc, ns_adp_argv, ns_adp_bind_args, ns_adp_break, ns_adp_debug, ns_adp_debuginit, ns_adp_dir, ns_adp_dump, ns_adp_eval, ns_adp_exception, ns_adp_include, ns_adp_mime, ns_adp_mimetype, ns_adp_parse, ns_adp_puts, ns_adp_registeradp, ns_adp_registerproc, ns_adp_registertag, ns_adp_return, ns_adp_safeeval, ns_adp_stats, ns_adp_stream, ns_adp_tell, ns_adp_trunc

Category Documentation - Category Core Tcl API