You can use custom exception in HTML channels to make exception handling more customized.
package com.ibm.btt.sample.html; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.ibm.btt.base.DSEInvalidArgumentException; import com.ibm.btt.base.DSEObjectNotFoundException; import com.ibm.btt.channel.ChannelInitializer; import com.ibm.btt.clientserver.ChannelContext; import com.ibm.btt.cs.DefaultExceptionHandler; import com.ibm.btt.cs.html.HtmlExceptionHandler; /** * This class defines the constants represent BTT technical channels */ 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(); } } } }In this example, the handler opens an error page helloWorldException.jsp when the RuntimeException is caught.
<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>