Please be sure to use code tags when posting code to the forums. Unformatted or unindented code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please click this link ⇒ UseCodeTags ⇐ for more information.
Properly indented and formatted code greatly increases the probability that your question will get quicker, better answers.
If you're using Tomcat, you don't need to write this yourself.
Look for and uncoment "RequestDumperValve" in you tomcat/conf/server.xml file.
As Bear mentioned, the output usually goes to logs (which is better than having it go to the console).
If you're on a *nix system, you can use tail -f <filename> to follow the file as it's updated from your console.
For windows users there are programs like mTail that do the same thing.
Note: this Valve is now deprecated in favor of the RequestDumperFilter, which does the same thing in a portable manner. This Filter is included in the examples application: see $CATALINA_HOME/webapps/examples/WEB-INF/classes/filters for the source.
not sure what this means by "portable manner" but I thought I'd note it here.
By "portable" I think they mean "works in all spec compliant containers". Valves are Tomcat specific.
Hopefully they will keep it around.
The advantage to a valve is that it is at the container level so can be run on any app (or all apps in the container), without touching the internals of the applications themselves.