Bossicard-san wrote:
> > haven't had time, but one of the first things I want to modify in the
> > sample servlet is the anchor generator which appears to force the context
> > name to "/Xindice" for all drill-down links.
>
> Oh Yes! Please do! I only wanted to quickly fix a bug in the
> XindiceServlet. I have no experience in JSP/Servlet so it's really a hack
> (but it's sufficient for a debug session).
OK. With a request like that, I made the time. It was a trivial fix.
Included please find the
cvs diff -u java/src/org/apache/xindice/server/XindiceServlet.java
named XindiceServlet.java.diff.
I tested it by copying dist/xindice-1.1b.war to ${TOMCAT_HOME}/webapps and
restarting Tomcat. Accessing http://localhost:8180/xindice-1.1b brought up
the "THIS IS AN UGLY DEBUG TOOL!" page, and the "db" link now corretly goes
to http://localhost:8180/xindice-1.1b?/db.
Shutdown Tomcat, rename ${TOMCAT_HOME}/webapps/xindice-1.1b to anything you
like, and the UGLY DEBUG TOOL just works now. (You don't have a copyright on
that name, do you? I kind of like it.)
Please review and check-in.
> If you could write some JSP pages for a nice Xindice browser (no update
> necessary) it would be great!
That's not so trivial. ;-)
As for placing the DB into WEB-INF, I see your point. How about having a
special prefix "context:/WEB-INF/db" become the result of:
getServletContext().getRealPath("/WEB-INF/db")
Otherwise, it's a real path. This at least allows a generic, platform
independent method of setting a path that is well known and can be deployed.
Since we're still in release candidate status, can the "./db" default be
changed? If anyone's been using the default, then they can still recover the
database from where it is by either setting the full path in system.xml or by
moving the directory to WEB-INF/db (or wherever they feel comfortable).
What do you think?
--
Michael Westbay
Work: Beacon-IT http://www.beacon-it.co.jp/
Home: http://www.seaple.icc.ne.jp/~westbay
Commentary: http://www.japanesebaseball.com/forum/
Index: java/src/org/apache/xindice/server/XindiceServlet.java
===================================================================
RCS file: /home/cvspublic/xml-xindice/java/src/org/apache/xindice/server/XindiceServlet.java,v
retrieving revision 1.7
diff -u -r1.7 XindiceServlet.java
--- java/src/org/apache/xindice/server/XindiceServlet.java 17 Nov 2002 20:32:47 -0000 1.7
+++ java/src/org/apache/xindice/server/XindiceServlet.java 26 Nov 2002 13:29:15 -0000
@@ -212,21 +212,23 @@
HttpServletResponse response)
throws ServletException, IOException {
try {
+ String contextPath = request.getContextPath();
StringBuffer sb = new StringBuffer();
String path = request.getQueryString();
sb.append("<html><body><center>");
if (path == null) {
sb.append("<h2>THIS IS AN UGLY DEBUG TOOL!</h2><p>");
sb.append("To browse the database, follow the link ");
- sb.append("<a href=\"Xindice?/" + db.getName() + "\">" + db.getName() + "</a>");
+ sb.append("<a href=\"" + contextPath + "?/" +
+ db.getName() + "\">" + db.getName() + "</a>");
} else {
// we have something to chew on
XPathPseudoParser parser = new XPathPseudoParser(path);
/* building the page once we have all the information */
sb.append("<table border=\"1\" width=\"90%\">");
- sb.append("<tr><td rowspan=\"1\" colspan=\"2\">" + getPathNavigation(parser) + "</td></tr>");
- sb.append("<tr><td valign=\"top\">" + getHierarchy(parser) + "</td>");
+ sb.append("<tr><td rowspan=\"1\" colspan=\"2\">" + getPathNavigation(parser, contextPath) + "</td></tr>");
+ sb.append("<tr><td valign=\"top\">" + getHierarchy(parser, contextPath) + "</td>");
sb.append("<td valign=\"top\">" + getDetailView(parser) + "</td></tr>");
sb.append("</table>");
}
@@ -246,11 +248,12 @@
}
}
- protected String getPathNavigation(XPathPseudoParser parser) {
+ protected String getPathNavigation(XPathPseudoParser parser,
+ String contextPath) {
String path = parser.getQuery();
StringBuffer result = new StringBuffer();
StringTokenizer st = new StringTokenizer(path, "/");
- String currentPath = "<a href=\"Xindice?";
+ String currentPath = "<a href=\"" + contextPath + "?";
while (st.hasMoreTokens()) {
String token = st.nextToken();
if (token.indexOf("&") > 0) {
@@ -263,7 +266,8 @@
return result.toString();
}
- protected String getHierarchy(XPathPseudoParser parser)
+ protected String getHierarchy(XPathPseudoParser parser,
+ String contextPath)
throws DBException, Exception {
StringBuffer result = new StringBuffer();
@@ -283,7 +287,8 @@
String[] cols = col.listCollections();
for (int i = 0; i < cols.length; i++) {
- result.append("<a href=\"Xindice?" + parser.getDatabase() + "/" + parser.getPath());
+ result.append("<a href=\"" + contextPath + "?" +
+ parser.getDatabase() + "/" + parser.getPath());
result.append("/");
result.append(cols[i]);
result.append("\">");
@@ -294,7 +299,8 @@
try {
String[] docs = col.listDocuments();
for (int i = 0; i < docs.length; i++) {
- result.append("<a href=\"Xindice?" + parser.getDatabase() + "/" + parser.getPath());
+ result.append("<a href=\"" + contextPath + "?" +
+ parser.getDatabase() + "/" + parser.getPath());
result.append("&");
result.append(docs[i]);
result.append("\">");