webMathematica involves running computations inside of a server. This poses a number of problems and constraints for debugging. In general, debugging anything running inside a server can be difficult.
If you are authoring webMathematica pages and find that your material does not work as you expect, you can use messages and print statements to resolve your problems. You can get message output returned in your web page with MSPGetMessages and the output of print statements with MSPGetPrintOutput. The capture of message and print output is described in the example Messages.jsp. It is probably a good idea to confirm that your calculations work correctly in an interactive Mathematica session.
In addition to message and print output, you can use the logging and monitor features provided by the system. These are described in more detail in the sections on Logging and the Kernel Monitor. The simplest technique is to look at the files written by the servlet engine. A more sophisticated way is to use the monitor, which can be accessed via a URL, for example, http://localhost:8080/webMathematica/KernelMonitor. If you increase the level of log output by setting VerboseLogs to true, you will generate more output.