code: public static void printFullStackTrace(PrintWriter out, ServletException e)
      {
          // determine the absolute root exception
          Throwable th = null;
  
          while (e != null)
          {
              th = e.getRootCause();
  
              if (th == null)
              {
                  th = e;
                  break;
              }
              else
                  e = th instanceof ServletException ? (ServletException)th : null;
          }
  
          // now print the root exception
          try
          {
              // if th is a ServletErrorReport, it's already encoded...if not, encode it
              if (th instanceof ServletErrorReport)
                  out.println("<HR width=\"100%\">\n" + th.getMessage() + "<BR>");
              else
                  out.println("<HR width=\"100%\">\n" + encodeChars(th.getMessage())+ "<BR>");
  
              // print the stack trace to a string writer so we can encode it if necessary and format
              // its output
              StringWriter sw = new StringWriter();
              PrintWriter pw = new PrintWriter(sw);
              th.printStackTrace(pw);
              pw.flush();
              String traceOut;
  
              // if it's a ServletErrorReport, it's already encoded...if not, encode it
              if (th instanceof ServletErrorReport)
                  traceOut = sw.toString();
              else
                  traceOut = encodeChars(sw.toString());
  
              // split the stack lines so they'll appear right in the browser
              StringTokenizer st = new StringTokenizer(traceOut, "\n");
  
              while (st.hasMoreTokens())
              {
                  out.println(st.nextToken());
                  out.println("<BR>&nbsp;&nbsp;&nbsp;&nbsp;");
              }
  
              out.println("<BR>");
          }
          catch (EmptyStackException ex)
          {
            com.ibm.wsspi.webcontainer.util.FFDCWrapper.processException(ex, "com.ibm.ws.webcontainer.servlet.DefaultErrorReporter.printFullStackTrace", "158");
          }
      }
docs: method rewritten for defect 105840