Debugging JSPs
2/13/2002
It turns out to be surprisingly difficult to debug JSPs.
The error messages are usually very cryptic,
and once your JSP has been translated to Java
and compiled,
the actual problem seems to have very little to do with the original JSP.
There is a good reason for that:
The program that is executing is quite different from the JSP!
Here are a few hints that will help you debug your JSPs.
- Use long variable names,
it makes searching your file much easier,
and it makes for fewer mistakes.
- Check your data files.
Bad data gives hard to understand messages.
- Validate your input data ...
- Go look at the java source files in
/opt/jakarta-tomcat-4.1.8/work/Standalone/localhost/swe432/jsp.
You can often find problems by looking at the source that
are not obvious when looking at the JSP.
- Remember to update your .class files in
/home/student/Apps/swe432a/WEB-INF/classes/
when you make changes.
If they are not updated,
you get some very hard to understand error messages.
- You need a useBean command when
creating objects of your own classes,
but not when creating objects of built-in classes
(such as ArrayList).
- When trying to diagnose a problem,
make small changes and try the JSP.
Then remove certain lines to see what happens.
Those will help you find where the problem is occurring.
- Look in the Log files after execution.
The log file on Hermes is:
$CATALINA_HOME/logs/catalina.out
- We don't have a symbolic debugger,
and print statements in your Java will not always return output
to the client.
One way to get more output if you're really stuck is to add
print statements that print to a local file.
- Different JSP engines give different error messages.
Try it on a different platform to see if you get a better message.
Good luck ...