This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I believe that in JSP there's a "log" object or method that will write to the server log. That will work better than attempting to log the stacktrace to the client. Or, if all else fails, write the stacktrace to System.out.
Actually, attempting to acquire a database connection in the way you described has 2 strikes against it.
1. We do not recommend putting logic in JSPs. Use the JSP for display and let a servlet do the dirty work.
2. Instead of the relatively expensive process of creating a Connection that you're using, well-written enterprise webapps use Connection Pools constructed by the webapp server.
Yes, the "brute force" ASP/PHP way is quicker to code, but J2EE is an expensive technology and the extra work up front should pay off in terms of overall maintainability and performance.
Speaking as a rabid Java fan, when I need something quick and dirty, I do use something like PHP, not J2EE.
Customer surveys are for companies who didn't pay proper attention to begin with.