Here's a nice way to debug the HTML produced by your servlets or PSPs.
1. Doing "View source" from the browser doesn't work if your page was
produced in response to a POST, since your browser may not re-POST the
form variables (mozilla doesn't, at least).
2. Debugging by hand is tedious, and if posible should be avoided by
using HTML validators.
3. You can't use online web validators (which validate a given URL) in
the context of a web application, because your web application often
requires a session id, which the validator obviously can't send to your
This approach uses Web Design Group's HTML validator, which can be
installed on your local machine (available at
You hook it up to your servlets so that the HTML output your servlet
produces is automatically validated, and the validation output and full
HTML source (with highlighted errors) is appended to the normal output
and sent to the browser.
A screenshot is worth 1k words:
1. Install the WDG offline-validator. In particular, you need the
"validate" script which can be called from the command line.
Debian users: apt-get install wdg-html-validator
2. Apply the patch at
to webware. This makes it possible to get the accumulated HTML in the
response object from within your servlets, before the response has been
3. Add the validateHTML method (available at
http://www.opensky.ca/~jdhildeb/webware_validator.py ) to your SitePage,
and call it at the end of writeBodyParts (you'll have to override
Page.writeBodyParts() if you haven't already done so).
validateHTML won't get all the HTML produced by your servlet if you call
response.flush() explicitly, so don't do that. :)
Jason D. Hildebrand