1 20 package org.enhydra.barracuda.plankton.exceptions; 21 22 import java.io.*; 23 import java.util.*; 24 import javax.servlet.*; 25 import javax.servlet.http.*; 26 27 30 public class ExceptionUtil { 31 32 39 public static void logExceptionAsHTML (PrintWriter out, NestableException e, HttpServletRequest req) { 40 out.println("<html>"); 41 out.println("<head>"); 42 out.println("<title>Unexpected exception!</title>"); 43 out.println("</head>"); 44 out.println("<body>"); 45 46 out.println("<h1>Error: EventException</h1>"); 47 out.println("<p>There was an unexpected error while servicing this request...please contact your application administrator and notify them of the problem."); 48 out.println("<p>Error dispatching request: "+e.getMessage()); 49 out.println("<p>Exception:<br>"); 50 out.println("<pre>"); e.printStackTrace(out); 52 out.println("</pre>"); Exception rootException = NestableException.getRootException(e); 54 if (rootException!=e) { 55 out.println("<p>Root Exception:<br>"); 56 out.println("<pre>"); rootException.printStackTrace(out); 58 out.println("</pre>"); } 60 61 out.println("<p>Parameters:"); 62 Enumeration enum = req.getParameterNames(); 63 while (enum.hasMoreElements()) { 64 String key = (String) enum.nextElement(); 65 String val = (String) req.getParameter(key); 66 out.println("<br> key:"+key+" value:"+val); 67 } 68 69 out.println("<br>RequestURI:"+req.getRequestURI()); 70 out.println("<br>ServletPath:"+req.getServletPath()); 71 out.println("<br>PathInfo:"+req.getPathInfo()); 72 out.println("<br>PathTranslated:"+req.getPathTranslated()); 73 74 out.println("</body>"); 75 out.println("</html>"); 76 } 77 78 } 79 | Popular Tags |