juergen 2002/08/19 06:18:23
Modified: src/webdav/server/org/apache/slide/webdav/util
DirectoryIndexGenerator.java
Log:
I18N characters are now displayed in an unencoded way (the url is still encoded).
Revision Changes Path
1.2 +26 -13
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/DirectoryIndexGenerator.java
Index: DirectoryIndexGenerator.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/DirectoryIndexGenerator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DirectoryIndexGenerator.java 13 Jun 2002 13:10:58 -0000 1.1
+++ DirectoryIndexGenerator.java 19 Aug 2002 13:18:23 -0000 1.2
@@ -89,7 +89,7 @@
import org.apache.slide.webdav.WebdavServletConfig;
/**
- * Utility class that encapsulates the generation of HTML directory index
+ * Utility class that encapsulates the generation of HTML directory index
* pages.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Christopher Lenz</a>
@@ -137,7 +137,7 @@
/**
* Constructor.
- *
+ *
* @param nat the namespace access token
*/
public DirectoryIndexGenerator(NamespaceAccessToken nat,
@@ -154,6 +154,20 @@
}
this.config = config;
}
+ // Little helpers to create character refrences
+ private String stringToCharacterRef(String val) {
+ StringBuffer result = new StringBuffer(val.length() * 8);
+ for (int i = 0; i < val.length(); i++) {
+ result.append(charToCharacterRef(val.charAt(i)));
+ }
+ return result.toString();
+ }
+
+ private String charToCharacterRef(char val) {
+ StringBuffer result = new StringBuffer(8);
+ result.append("&#x").append(Integer.toHexString((int)
val).toUpperCase()).append(";");
+ return result.toString();
+ }
// --------------------------------------------------------- Public Methods
@@ -161,17 +175,17 @@
/**
* Display a directory browsing page.
- *
+ *
* @param req the HTTP request
* @param res the HTTP response
- * @throw IOException if an IO exception occurrs while writing the
+ * @throw IOException if an IO exception occurrs while writing the
* response
* @throw SlideException if an exception occurrs accessing Slide
*/
public void generate(HttpServletRequest req, HttpServletResponse res)
throws IOException, SlideException {
- res.setContentType("text/html");
+ res.setContentType("text/html; charset=\"UTF-8\"");
String contextPath = req.getContextPath();
if (contextPath == null)
@@ -231,10 +245,10 @@
String parent = name.substring(0, name.lastIndexOf("/"));
writer.print("<tr><td colspan=\"5\" bgcolor=\"#ffffff\">\r\n");
writer.print("<a href=\"");
- writer.print(WebdavUtils.encodeURL(contextPath));
+ writer.print(WebdavUtils.encodeURL(contextPath, "UTF-8"));
if (parent.equals(""))
parent = "/";
- writer.print(parent);
+ writer.print(parent); // I18N chars
writer.print("\">");
writer.print(Messages.format
("org.apache.slide.webdav.GetMethod.parent",
@@ -332,8 +346,7 @@
writer.print("<a href=\"");
writer.print(WebdavUtils.encodeURL(contextPath + currentResource));
writer.print("\"><tt>");
- writer.print(WebdavUtils.encodeURL(trimmed, "UTF-8"));
- // make it I18N
+ writer.print(stringToCharacterRef(trimmed)); // I18N chars
if (WebdavUtils.isCollection(currentDescriptor)) {
writer.print("/");
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>