00001 package cedar.jetweb.html; 00002 00003 import java.io.PrintWriter; 00004 import java.io.BufferedWriter; 00005 import java.io.BufferedReader; 00006 import java.io.FileInputStream; 00007 import java.io.InputStreamReader; 00008 import java.io.File; 00009 import java.io.FileWriter; 00010 import java.io.IOException; 00011 import java.text.ParseException; 00012 00013 import cedar.jetweb.JetWebConfig; 00014 import cedar.jetweb.JetWebException; 00015 00016 00025 public abstract class HTMLErrorWriter { 00026 00027 private static BufferedWriter ofile; 00028 00036 public static void write(PrintWriter out, Exception ex){ 00037 00038 try{ 00039 ofile = new BufferedWriter(out); 00040 write(ofile,ex); 00041 00042 } catch (Exception e) { 00043 System.out.println("error"); 00044 } 00045 } 00046 00047 00048 00056 public static void write(BufferedWriter ofile, Exception ex){ 00057 00058 try{ 00059 00060 writeHeader(ofile,"JetWeb Error"); 00061 00062 ofile.write("<PRE>"+ex.getMessage()+"</PRE>"); 00063 00064 //writeTrailer(ofile); 00065 ofile.close(); 00066 00067 // Write the stack trace to the log file. 00068 System.out.println("Writing exception error "+ex.getMessage()); 00069 ex.printStackTrace(System.out); 00070 00071 } catch (Exception e) { 00072 System.out.println("error"); 00073 } 00074 } 00075 00076 private static void writeHeader(BufferedWriter ofile, String title){ 00077 try { 00078 ofile.write("<TITLE>"+title+"</TITLE>"); 00079 ofile.newLine(); 00080 } 00081 catch (IOException e) { 00082 System.out.println("Could not open output stream for error message."); 00083 } 00084 } 00085 /* 00086 private static void writeTrailer(BufferedWriter ofile){ 00087 00088 try { 00089 ofile.write("<hr noshade size=3><em>jetweb@hep.ucl.ac.uk</em>"); 00090 ofile.newLine(); 00091 ofile.write("</BODY>"); 00092 ofile.newLine(); 00093 ofile.close(); 00094 } 00095 catch (IOException e) { 00096 System.out.println("Could not open error output"); 00097 } 00098 00099 } 00100 */ 00101 } 00102 00103 00104 00105 00106 00107 00108 00109 00110 00111 00112 00113
Generated Wed Jan 17 09:14:27 GMT 2007