tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/valves ErrorReportValve.java
Date Mon, 15 Oct 2001 01:11:59 GMT
remm        01/10/14 18:11:59

  Modified:    catalina/src/share/org/apache/catalina/servlets
                        DefaultServlet.java
               catalina/src/share/org/apache/catalina/valves
                        ErrorReportValve.java
  Log:
  - Make the look of the directory listings consistent with the look of the
    status reports.
  - Use a string buffer for the directory listings. I'm not sure yet if it's better than
    directly writing to the writer.
  
  Revision  Changes    Path
  1.42      +76 -66    jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java
  
  Index: DefaultServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- DefaultServlet.java	2001/10/09 02:44:09	1.41
  +++ DefaultServlet.java	2001/10/15 01:11:59	1.42
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java,v
1.41 2001/10/09 02:44:09 remm Exp $
  - * $Revision: 1.41 $
  - * $Date: 2001/10/09 02:44:09 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java,v
1.42 2001/10/15 01:11:59 remm Exp $
  + * $Revision: 1.42 $
  + * $Date: 2001/10/15 01:11:59 $
    *
    * ====================================================================
    *
  @@ -122,7 +122,7 @@
    *
    * @author Craig R. McClanahan
    * @author Remy Maucherat
  - * @version $Revision: 1.41 $ $Date: 2001/10/09 02:44:09 $
  + * @version $Revision: 1.42 $ $Date: 2001/10/15 01:11:59 $
    */
   
   public class DefaultServlet
  @@ -1459,20 +1459,26 @@
           }
           PrintWriter writer = new PrintWriter(osWriter);
   
  -        // Render the page header
  -        writer.print("<html>\r\n");
  -        writer.print("<head>\r\n");
  -        writer.print("<title>");
  -        writer.print(sm.getString("directory.title", name));
  -        writer.print("</title>\r\n</head>\r\n");
  -        writer.print("<body bgcolor=\"white\">\r\n");
  -        writer.print("<table width=\"90%\" cellspacing=\"0\"" +
  -                     " cellpadding=\"5\" align=\"center\">\r\n");
  +        StringBuffer sb = new StringBuffer();
   
  -        // Render the in-page title
  -        writer.print("<tr><td colspan=\"3\"><font size=\"+2\">\r\n<strong>");
  -        writer.print(sm.getString("directory.title", name));
  -        writer.print("</strong>\r\n</font></td></tr>\r\n");
  +        // Render the page header
  +        sb.append("<html>\r\n");
  +        sb.append("<head>\r\n");
  +        sb.append("<title>");
  +        sb.append(sm.getString("directory.title", name));
  +        sb.append("</title>\r\n");
  +        sb.append("<STYLE><!--");
  +        sb.append("H1{font-family : sans-serif,Arial,Tahoma;color : white;background-color
: #0086b2;} ");
  +        sb.append("H3{font-family : sans-serif,Arial,Tahoma;color : white;background-color
: #0086b2;} ");
  +        sb.append("BODY{font-family : sans-serif,Arial,Tahoma;color : black;background-color
: white;} ");
  +        sb.append("B{color : white;background-color : #0086b2;} ");
  +        sb.append("A{color : black;} ");
  +        sb.append("HR{color : #0086b2;} ");
  +        sb.append("--></STYLE> ");
  +        sb.append("</head>\r\n");
  +        sb.append("<body>");
  +        sb.append("<h1>");
  +        sb.append(sm.getString("directory.title", name));
   
           // Render the link to our parent (if required)
           String parentDirectory = name;
  @@ -1483,32 +1489,38 @@
           int slash = parentDirectory.lastIndexOf('/');
           if (slash >= 0) {
               String parent = name.substring(0, slash);
  -            writer.print("<tr><td colspan=\"3\" bgcolor=\"#ffffff\">\r\n");
  -            writer.print("<a href=\"");
  -            writer.print(rewriteUrl(contextPath));
  +            sb.append(" - <a href=\"");
  +            sb.append(rewriteUrl(contextPath));
               if (parent.equals(""))
                   parent = "/";
  -            writer.print(rewriteUrl(parent));
  +            sb.append(rewriteUrl(parent));
               if (!parent.endsWith("/"))
  -                writer.print("/");
  -            writer.print("\">");
  -            writer.print(sm.getString("directory.parent", parent));
  -            writer.print("</a>\r\n");
  -            writer.print("</td></tr>\r\n");
  +                sb.append("/");
  +            sb.append("\">");
  +            sb.append("<b>");
  +            sb.append(sm.getString("directory.parent", parent));
  +            sb.append("</b>");
  +            sb.append("</a>");
           }
   
  +        sb.append("</h1>");
  +        sb.append("<HR size=\"1\" noshade>");
  +
  +        sb.append("<table width=\"100%\" cellspacing=\"0\"" +
  +                     " cellpadding=\"5\" align=\"center\">\r\n");
  +
           // Render the column headings
  -        writer.print("<tr bgcolor=\"#cccccc\">\r\n");
  -        writer.print("<td align=\"left\"><font size=\"+1\"><strong>");
  -        writer.print(sm.getString("directory.filename"));
  -        writer.print("</strong></font></td>\r\n");
  -        writer.print("<td align=\"center\"><font size=\"+1\"><strong>");
  -        writer.print(sm.getString("directory.size"));
  -        writer.print("</strong></font></td>\r\n");
  -        writer.print("<td align=\"right\"><font size=\"+1\"><strong>");
  -        writer.print(sm.getString("directory.lastModified"));
  -        writer.print("</strong></font></td>\r\n");
  -        writer.print("</tr>\r\n");
  +        sb.append("<tr>\r\n");
  +        sb.append("<td align=\"left\"><font size=\"+1\"><strong>");
  +        sb.append(sm.getString("directory.filename"));
  +        sb.append("</strong></font></td>\r\n");
  +        sb.append("<td align=\"center\"><font size=\"+1\"><strong>");
  +        sb.append(sm.getString("directory.size"));
  +        sb.append("</strong></font></td>\r\n");
  +        sb.append("<td align=\"right\"><font size=\"+1\"><strong>");
  +        sb.append(sm.getString("directory.lastModified"));
  +        sb.append("</strong></font></td>\r\n");
  +        sb.append("</tr>");
   
           try {
   
  @@ -1529,38 +1541,37 @@
                       trimmed.equalsIgnoreCase("META-INF"))
                       continue;
   
  -                writer.print("<tr");
  +                sb.append("<tr");
                   if (shade)
  -                    writer.print(" bgcolor=\"eeeeee\"");
  -                writer.print(">\r\n");
  +                    sb.append(" bgcolor=\"eeeeee\"");
  +                sb.append(">\r\n");
                   shade = !shade;
   
  -                writer.print("<td align=\"left\">&nbsp;&nbsp;\r\n");
  -                writer.print("<a href=\"");
  -                writer.print(rewriteUrl(contextPath));
  +                sb.append("<td align=\"left\">&nbsp;&nbsp;\r\n");
  +                sb.append("<a href=\"");
  +                sb.append(rewriteUrl(contextPath));
                   resourceName = rewriteUrl(name + resourceName);
  -                writer.print(resourceName);
  +                sb.append(resourceName);
                   if (childResourceInfo.collection)
  -                    writer.print("/");
  -                writer.print("\"><tt>");
  -                writer.print(trimmed);
  -
  +                    sb.append("/");
  +                sb.append("\"><tt>");
  +                sb.append(trimmed);
                   if (childResourceInfo.collection)
  -                    writer.print("/");
  -                writer.print("</tt></a></td>\r\n");
  +                    sb.append("/");
  +                sb.append("</tt></a></td>\r\n");
   
  -                writer.print("<td align=\"right\"><tt>");
  +                sb.append("<td align=\"right\"><tt>");
                   if (childResourceInfo.collection)
  -                    writer.print("&nbsp;");
  +                    sb.append("&nbsp;");
                   else
  -                    writer.print(renderSize(childResourceInfo.length));
  -                writer.print("</tt></td>\r\n");
  +                    sb.append(renderSize(childResourceInfo.length));
  +                sb.append("</tt></td>\r\n");
   
  -                writer.print("<td align=\"right\"><tt>");
  -                writer.print(renderLastModified(childResourceInfo.date));
  -                writer.print("</tt></td>\r\n");
  +                sb.append("<td align=\"right\"><tt>");
  +                sb.append(renderLastModified(childResourceInfo.date));
  +                sb.append("</tt></td>\r\n");
   
  -                writer.print("</tr>\r\n");
  +                sb.append("</tr>\r\n");
               }
   
           } catch (NamingException e) {
  @@ -1569,16 +1580,15 @@
           }
   
           // Render the page footer
  -        writer.print("<tr><td colspan=\"3\">&nbsp;</td></tr>\r\n");
  -        writer.print("<tr><td colspan=\"3\" bgcolor=\"#cccccc\">");
  -        writer.print("<font size=\"-1\">");
  -        writer.print(Globals.SERVER_INFO);
  -        writer.print("</font></td></tr>\r\n");
  -        writer.print("</table>\r\n");
  -        writer.print("</body>\r\n");
  -        writer.print("</html>\r\n");
  +        sb.append("</table>\r\n");
  +
  +        sb.append("<HR size=\"1\" noshade>");
  +        sb.append("<h3>").append(Globals.SERVER_INFO).append("</h3>");
  +        sb.append("</body>\r\n");
  +        sb.append("</html>\r\n");
   
           // Return an input stream to the underlying bytes
  +        writer.write(sb.toString());
           writer.flush();
           return (new ByteArrayInputStream(stream.toByteArray()));
   
  
  
  
  1.6       +9 -6      jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/valves/ErrorReportValve.java
  
  Index: ErrorReportValve.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/valves/ErrorReportValve.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ErrorReportValve.java	2001/10/03 02:02:05	1.5
  +++ ErrorReportValve.java	2001/10/15 01:11:59	1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/valves/ErrorReportValve.java,v
1.5 2001/10/03 02:02:05 remm Exp $
  - * $Revision: 1.5 $
  - * $Date: 2001/10/03 02:02:05 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/valves/ErrorReportValve.java,v
1.6 2001/10/15 01:11:59 remm Exp $
  + * $Revision: 1.6 $
  + * $Date: 2001/10/15 01:11:59 $
    *
    * ====================================================================
    *
  @@ -104,7 +104,7 @@
    * @author Craig R. McClanahan
    * @author <a href="mailto:nicolaken@supereva.it">Nicola Ken Barozzi</a> Aisa
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version $Revision: 1.5 $ $Date: 2001/10/03 02:02:05 $
  + * @version $Revision: 1.6 $ $Date: 2001/10/15 01:11:59 $
    */
   
   public class ErrorReportValve
  @@ -302,13 +302,15 @@
           sb.append(Globals.SERVER_INFO).append(" - ");
           sb.append(sm.getString("errorReportValve.errorReport"));
           sb.append("</title>");
  -        sb.append("<STYLE><!--H1{font-family : sans-serif,Arial,Tahoma;color :
white;background-color : #0086b2;} ");
  +        sb.append("<STYLE><!--");
  +        sb.append("H1{font-family : sans-serif,Arial,Tahoma;color : white;background-color
: #0086b2;} ");
  +        sb.append("H3{font-family : sans-serif,Arial,Tahoma;color : white;background-color
: #0086b2;} ");
           sb.append("BODY{font-family : sans-serif,Arial,Tahoma;color : black;background-color
: white;} ");
           sb.append("B{color : white;background-color : #0086b2;} ");
           sb.append("HR{color : #0086b2;} ");
           sb.append("--></STYLE> ");
           sb.append("</head><body>");
  -        sb.append("<h1>").append(Globals.SERVER_INFO).append(" - ");
  +        sb.append("<h1>");
           sb.append(sm.getString("errorReportValve.statusHeader",
                                  "" + statusCode, message)).append("</h1>");
           sb.append("<HR size=\"1\" noshade>");
  @@ -349,6 +351,7 @@
           }
   
           sb.append("<HR size=\"1\" noshade>");
  +        sb.append("<h3>").append(Globals.SERVER_INFO).append("</h3>");
           sb.append("</body></html>");
   
           try {
  
  
  

Mime
View raw message