author | John Kern <johnk@symbian.org> |
Fri, 29 Jan 2010 16:32:12 -0800 | |
changeset 62 | 040d2c998a7b |
parent 3 | d3477de62514 |
permissions | -rw-r--r-- |
3
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
1 |
// $Id: ErrorReportHTML.java,v 1.4 2007-07-13 13:32:21 julien Exp $ |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
2 |
// Author: Jean-Guilhem Rouel |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
3 |
// (c) COPYRIGHT MIT, ERCIM and Keio, 2003. |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
4 |
// Please first read the full copyright statement in file COPYRIGHT.html |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
5 |
package org.w3c.css.error; |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
6 |
|
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
7 |
import java.io.DataInputStream; |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
8 |
import java.io.EOFException; |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
9 |
import java.io.IOException; |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
10 |
import java.io.PrintWriter; |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
11 |
import java.net.URL; |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
12 |
|
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
13 |
import org.apache.velocity.exception.ResourceNotFoundException; |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
14 |
import org.w3c.css.util.ApplContext; |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
15 |
import org.w3c.css.util.Util; |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
16 |
import org.xml.sax.SAXParseException; |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
17 |
|
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
18 |
/** |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
19 |
* ErrorReportHTML<br /> |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
20 |
* Created: Jul 13, 2005 2:05:51 PM<br /> |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
21 |
* This class is used to create an (x)html page when a URI error is thrown by |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
22 |
* the servlet |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
23 |
*/ |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
24 |
public class ErrorReportHTML extends ErrorReport { |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
25 |
|
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
26 |
// ApplContext ac; |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
27 |
String title; |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
28 |
Exception e; |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
29 |
|
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
30 |
public ErrorReportHTML(ApplContext ac, String title, String output, Exception e) { |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
31 |
// ac is not used for now, but may be useful |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
32 |
// this.ac = ac; |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
33 |
this.title = title; |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
34 |
this.e = e; |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
35 |
} |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
36 |
|
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
37 |
/** |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
38 |
* @see org.w3c.css.error.ErrorReport#print(java.io.PrintWriter) |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
39 |
*/ |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
40 |
public void print(PrintWriter out) { |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
41 |
try { |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
42 |
URL localURL = ErrorReportHTML.class.getResource("error.html"); |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
43 |
DataInputStream in = new DataInputStream(localURL.openStream()); |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
44 |
try { |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
45 |
while (true) { |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
46 |
out.print((char) in.readUnsignedByte()); |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
47 |
} |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
48 |
} catch (EOFException eof) { |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
49 |
out.println("<h2>Target: " + Util.escapeHTML(title) + "</h2>"); |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
50 |
out.println("<div class=\"error\">"); |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
51 |
if (e instanceof ResourceNotFoundException) { |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
52 |
out.println("<p>" + e.toString() + "</p>"); |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
53 |
} else if (e instanceof IOException) { |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
54 |
out.println("<p>I/O Error: "); |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
55 |
out.println(Util.escapeHTML(e.getMessage())); |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
56 |
} else if (e instanceof SAXParseException) { |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
57 |
SAXParseException saxe = (SAXParseException) e; |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
58 |
out.println("<p>Please, validate your XML document" + " first!</p>"); |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
59 |
if (saxe.getLineNumber() != -1) { |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
60 |
out.print("<p>Line "); |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
61 |
out.print(saxe.getLineNumber()); |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
62 |
out.println("</p>"); |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
63 |
} |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
64 |
if (saxe.getColumnNumber() != -1) { |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
65 |
out.print("<p>Column "); |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
66 |
out.print(saxe.getColumnNumber()); |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
67 |
out.print("</p>\n"); |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
68 |
} |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
69 |
out.println("<p>" + Util.escapeHTML(e.getMessage())); |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
70 |
} else if (e instanceof NullPointerException) { |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
71 |
out.println("<p>Oups! Internal error!</p><p>"); |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
72 |
e.printStackTrace(); |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
73 |
} else { |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
74 |
out.println(e.toString()); |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
75 |
} |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
76 |
out.println("</p></div>\n<hr />\n<p><img src='images/mwc" |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
77 |
+ "ss.gif' alt='made with CSS' /></p>\n<addres" + "s><a href='Email.html'>www-validator-css</a" |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
78 |
+ "></address>\n</body></html>"); |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
79 |
out.flush(); |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
80 |
/* |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
81 |
* System.err.println("CSS Validator: request failed."); |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
82 |
* e.printStackTrace(); |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
83 |
*/ |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
84 |
} |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
85 |
} catch (Exception unknown) { |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
86 |
if (out != null) { |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
87 |
out.println("org.w3c.css.servlet.CssValidator: couldn't " + "load error file"); |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
88 |
out.flush(); |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
89 |
} |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
90 |
unknown.printStackTrace(); |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
91 |
} finally { |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
92 |
if (out != null) { |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
93 |
out.close(); |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
94 |
} |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
95 |
} |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
96 |
} |
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
97 |
|
d3477de62514
Added new wizards for importing WRT projects. Added CSS Validator.
TasneemS@US-TASNEEMS
parents:
diff
changeset
|
98 |
} |