The Workbench lets you debug Mathematica code as it executes in the webMathematica server. The steps in this process are described in this page.
In order to debug code on the server, it has to be launched in a special way so that Mathematica listens for a connection from the Workbench.
If you launch the server directly from the Workbench it is particularly easy to set it up to listen for connections. This is described in the section Direct Launch and Connect.
However, you may not want to launch from the Workbench. For example, you might want to launch as a service or you might want to launch so that you can debug Java code. In this case, you need to configure the webMathematica configuration. It is described in the section Indirect Launch and Connect.
The Workbench has to connect to Mathematica so that it can manage breakpoints and other issues for debugging.
The code running in the server also has to be in a project in the Workbench. The simplest way to do this is to create it in the Workbench and deploy it to webMathematica.
When the server is launched, the connection is made, and your code is in place, you can execute and debug your code.