!--a11y-->
Exception Listener 
Whenever errors occur, JCo throws an exception. All exceptions that occur in JCo are passed on to the registered Exception and Error Listener.

The application must process the exceptions separately in the method handleRequest()(that is, the exceptions that it generates itself). Exceptions from the application coding are not passed on to the Listener.
JCO.ServerExceptionListener and JCO.ServerStateChangedListener:

public class MyExceptionAndErrorListener implements JCO.ServerExceptionListener, JCO.ServerErrorListener {
public void serverExceptionOccurred(JCO.Server server, Exception ex) { System.out.println("Exception in server " + server.getProgID() + ":\n" + ex); ex.printStackTrace(); } public void serverErrorOccurred(JCO.Server server, Error er) { System.out.println("Error in server " + server.getProgID() + ":\n" + er); er.printStackTrace(); } } |
Register the Listener class with and JCO.addServerExceptionListener:

public class SecondExample extends FirstExample { public static void main(String[] args) { MyExceptionAndErrorListener l = new MyExceptionAndErrorListener(); JCO.addServerErrorListener(l); JCO.addServerExceptionListener(l); FirstExample.startServers() ; } } |
