diff --git a/src/share/classes/com/sun/tools/hat/internal/server/AllClassesQuery.java b/src/share/classes/com/sun/tools/hat/internal/server/AllClassesQuery.java index d44a8fc2ecf78f5d39f0fea7d01bd5ed9dec07d7..bdf01b8d5c6748ba92aba14fb3669123fa15d79d 100644 --- a/src/share/classes/com/sun/tools/hat/internal/server/AllClassesQuery.java +++ b/src/share/classes/com/sun/tools/hat/internal/server/AllClassesQuery.java @@ -84,7 +84,7 @@ class AllClassesQuery extends QueryHandler { lastPackage = pkg; printClass(clazz); if (clazz.getId() != -1) { - out.print(" [" + clazz.getIdString() + "]"); + print(" [" + clazz.getIdString() + "]"); } out.println("
"); } diff --git a/src/share/classes/com/sun/tools/hat/internal/server/ClassQuery.java b/src/share/classes/com/sun/tools/hat/internal/server/ClassQuery.java index 1d5782390ceb430195567af3f781360d92dc6e92..f13572a22cc625e99b97ce8024c1e333ea37484c 100644 --- a/src/share/classes/com/sun/tools/hat/internal/server/ClassQuery.java +++ b/src/share/classes/com/sun/tools/hat/internal/server/ClassQuery.java @@ -112,12 +112,12 @@ class ClassQuery extends QueryHandler { out.println("

Instances

"); printAnchorStart(); - out.print("instances/" + encodeForURL(clazz)); + print("instances/" + encodeForURL(clazz)); out.print("\">"); out.println("Exclude subclasses
"); printAnchorStart(); - out.print("allInstances/" + encodeForURL(clazz)); + print("allInstances/" + encodeForURL(clazz)); out.print("\">"); out.println("Include subclasses
"); @@ -126,19 +126,19 @@ class ClassQuery extends QueryHandler { out.println("

New Instances

"); printAnchorStart(); - out.print("newInstances/" + encodeForURL(clazz)); + print("newInstances/" + encodeForURL(clazz)); out.print("\">"); out.println("Exclude subclasses
"); printAnchorStart(); - out.print("allNewInstances/" + encodeForURL(clazz)); + print("allNewInstances/" + encodeForURL(clazz)); out.print("\">"); out.println("Include subclasses
"); } out.println("

References summary by Type

"); printAnchorStart(); - out.print("refsByType/" + encodeForURL(clazz)); + print("refsByType/" + encodeForURL(clazz)); out.print("\">"); out.println("References summary by type"); diff --git a/src/share/classes/com/sun/tools/hat/internal/server/HttpReader.java b/src/share/classes/com/sun/tools/hat/internal/server/HttpReader.java index f86c8caa8e27973efbe7df0569ccf82c2a69dc8a..f08c9875c6700fc7fdd95245ec9c7a723e1fe4de 100644 --- a/src/share/classes/com/sun/tools/hat/internal/server/HttpReader.java +++ b/src/share/classes/com/sun/tools/hat/internal/server/HttpReader.java @@ -41,21 +41,17 @@ package com.sun.tools.hat.internal.server; import java.net.Socket; -import java.net.ServerSocket; -import java.net.InetAddress; import java.io.InputStream; import java.io.BufferedInputStream; import java.io.IOException; -import java.io.Writer; import java.io.BufferedWriter; import java.io.PrintWriter; -import java.io.OutputStream; import java.io.OutputStreamWriter; -import java.io.BufferedOutputStream; import com.sun.tools.hat.internal.model.Snapshot; import com.sun.tools.hat.internal.oql.OQLEngine; +import com.sun.tools.hat.internal.util.Misc; public class HttpReader implements Runnable { @@ -87,7 +83,7 @@ public class HttpReader implements Runnable { outputError("Protocol error"); } int data; - StringBuffer queryBuf = new StringBuffer(); + StringBuilder queryBuf = new StringBuilder(); while ((data = in.read()) != -1 && data != ' ') { char ch = (char) data; queryBuf.append(ch); @@ -217,7 +213,7 @@ public class HttpReader implements Runnable { private void outputError(String msg) { out.println(); out.println(""); - out.println(msg); + out.println(Misc.encodeHtml(msg)); out.println(""); } diff --git a/src/share/classes/com/sun/tools/hat/internal/server/InstancesCountQuery.java b/src/share/classes/com/sun/tools/hat/internal/server/InstancesCountQuery.java index 724b549ca4bd24e2d60fa9d6e7cb6dfd0e455f1d..7e87543ef99a84d5bf46eba573a72f7dffdc276f 100644 --- a/src/share/classes/com/sun/tools/hat/internal/server/InstancesCountQuery.java +++ b/src/share/classes/com/sun/tools/hat/internal/server/InstancesCountQuery.java @@ -102,7 +102,7 @@ class InstancesCountQuery extends QueryHandler { int count = clazz.getInstancesCount(false); print("" + count); printAnchorStart(); - out.print("instances/" + encodeForURL(classes[i])); + print("instances/" + encodeForURL(classes[i])); out.print("\"> "); if (count == 1) { print("instance"); @@ -121,7 +121,7 @@ class InstancesCountQuery extends QueryHandler { } print("("); printAnchorStart(); - out.print("newInstances/" + encodeForURL(classes[i])); + print("newInstances/" + encodeForURL(classes[i])); out.print("\">"); print("" + newInst + " new"); out.print(") "); diff --git a/src/share/classes/com/sun/tools/hat/internal/server/OQLHelp.java b/src/share/classes/com/sun/tools/hat/internal/server/OQLHelp.java index 6aaa909109a4f3eb2eee0c8658e7816a5bf9c9e5..730d2b7672dde1b32c9f156a56a5e4c64def1566 100644 --- a/src/share/classes/com/sun/tools/hat/internal/server/OQLHelp.java +++ b/src/share/classes/com/sun/tools/hat/internal/server/OQLHelp.java @@ -54,10 +54,7 @@ class OQLHelp extends QueryHandler { out.print((char)ch); } } catch (Exception exp) { - out.println(exp.getMessage()); - out.println("
");
-            exp.printStackTrace(out);
-            out.println("
"); + printException(exp); } } } diff --git a/src/share/classes/com/sun/tools/hat/internal/server/OQLQuery.java b/src/share/classes/com/sun/tools/hat/internal/server/OQLQuery.java index 8e5ec5e289468cfa16f5d22ceafa1a55a7de8ba6..3e99bbcbb74103f4fbb2ae6a6ba93095ce2a1c47 100644 --- a/src/share/classes/com/sun/tools/hat/internal/server/OQLQuery.java +++ b/src/share/classes/com/sun/tools/hat/internal/server/OQLQuery.java @@ -32,10 +32,7 @@ package com.sun.tools.hat.internal.server; -import com.sun.tools.hat.internal.model.*; import com.sun.tools.hat.internal.oql.*; -import com.sun.tools.hat.internal.util.ArraySorter; -import com.sun.tools.hat.internal.util.Comparer; /** * This handles Object Query Language (OQL) queries. @@ -68,7 +65,7 @@ class OQLQuery extends QueryHandler { out.println("

"); out.println(""); out.println("

"); @@ -91,10 +88,7 @@ class OQLQuery extends QueryHandler { try { out.println(engine.toHtml(o)); } catch (Exception e) { - out.println(e.getMessage()); - out.println("
");
-                             e.printStackTrace(out);
-                             out.println("
"); + printException(e); } out.println(""); return false; @@ -102,10 +96,7 @@ class OQLQuery extends QueryHandler { }); out.println(""); } catch (OQLException exp) { - out.println(exp.getMessage()); - out.println("
");
-            exp.printStackTrace(out);
-            out.println("
"); + printException(exp); } } diff --git a/src/share/classes/com/sun/tools/hat/internal/server/QueryHandler.java b/src/share/classes/com/sun/tools/hat/internal/server/QueryHandler.java index deda0f480588c2f00d91eca36404800257a93651..9a6d93de06a186ada757132b217a03fbd0b9baba 100644 --- a/src/share/classes/com/sun/tools/hat/internal/server/QueryHandler.java +++ b/src/share/classes/com/sun/tools/hat/internal/server/QueryHandler.java @@ -36,6 +36,7 @@ import java.io.PrintWriter; import com.sun.tools.hat.internal.model.*; import com.sun.tools.hat.internal.util.Misc; +import java.io.StringWriter; import java.net.URLEncoder; import java.io.UnsupportedEncodingException; @@ -96,7 +97,7 @@ abstract class QueryHandler { } protected void error(String msg) { - out.println(msg); + println(msg); } protected void printAnchorStart() { @@ -160,7 +161,6 @@ abstract class QueryHandler { out.println("null"); return; } - String name = clazz.getName(); printAnchorStart(); out.print("class/"); print(encodeForURL(clazz)); @@ -208,6 +208,15 @@ abstract class QueryHandler { } } + protected void printException(Throwable t) { + println(t.getMessage()); + out.println("
");
+        StringWriter sw = new StringWriter();
+        t.printStackTrace(new PrintWriter(sw));
+        print(sw.toString());
+        out.println("
"); + } + protected void printHex(long addr) { if (snapshot.getIdentifierSize() == 4) { out.print(Misc.toHex((int)addr)); @@ -223,4 +232,8 @@ abstract class QueryHandler { protected void print(String str) { out.print(Misc.encodeHtml(str)); } + + protected void println(String str) { + out.println(Misc.encodeHtml(str)); + } } diff --git a/src/share/classes/com/sun/tools/hat/internal/server/RefsByTypeQuery.java b/src/share/classes/com/sun/tools/hat/internal/server/RefsByTypeQuery.java index 5e7de9a8866871b1d9eb08de81a732b7e155a51d..3337b4715903a762a4bd35e3c477a777be47f04f 100644 --- a/src/share/classes/com/sun/tools/hat/internal/server/RefsByTypeQuery.java +++ b/src/share/classes/com/sun/tools/hat/internal/server/RefsByTypeQuery.java @@ -89,7 +89,7 @@ public class RefsByTypeQuery extends QueryHandler { out.println("

"); printClass(clazz); if (clazz.getId() != -1) { - out.println("[" + clazz.getIdString() + "]"); + println("[" + clazz.getIdString() + "]"); } out.println("

"); @@ -125,9 +125,9 @@ public class RefsByTypeQuery extends QueryHandler { JavaClass clazz = classes[i]; out.println(""); out.print(""); - out.print(clazz.getName()); + print(clazz.getName()); out.println(""); out.println(""); out.println(map.get(clazz));