Runtime components : Core components : Exceptions : Custom exception handling : Using custom exception in HTML channel
  
Using custom exception in HTML channel
You can use custom exception in HTML channels to make exception handling more customized.
About the task
After users define the HTML channel exception handler, and add the configuration in btt.xml, when this kind of exception is caught at an HTML channel layer, HTML custom exception handler executes it according to the predefined logic, such as turning to one specific error page.
Process
1 Create an error page, like helloWorldException.jsp and register this error page as errorPage for HTMLClient channel.
2 Defining custom exception handler by overriding preProcessException() to set the error page when an exception occurs:
public class CustomHtmlExceptionHandler extends HtmlExceptionHandler{
  public void preProcessException(ChannelContext context, Throwable ex) {
    System.out.println("In CCL : The custom html exception handler is invoked!");

    if (ex instanceof RuntimeException){
      try {
        // set helloWorldException.jsp as error page
        super.setErrorPage("helloWorldException.jsp");

      }
      catch (DSEInvalidArgumentException e) {
        e.printStackTrace();
      }
      catch (DSEObjectNotFoundException e) {
        e.printStackTrace();
      }
    }
  }
}
3 In this example, the handler opens an error page helloWorldException.jsp when the RuntimeException is caught.
4 Register the exception handler in btt.xml by adding the following lines to btt.xml.
<kColl id="html">
  <field id="cookies" value="true"/>
  <field id="encoding" value="UTF-8"/>
  <field id="runInSession" value="true"/>
  <field id="requestHandler" value="com.ibm.btt.cs.html.HtmlRequestHandler"/>
  <field id="presentationHandler" value="com.ibm.btt.cs.html.HtmlPresentationHandler"/>
  <field id="exceptionHandler" value="com.ibm.btt.sample.html.CustomHtmlExceptionHandler"/>
</kColl>
Go up to
Custom exception handling