tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Palmer <johnpalm...@gmail.com>
Subject ErrorReportValve styling (CSS) not included when both showReport and showServerInfo set to false
Date Thu, 10 May 2018 15:27:43 GMT
while it's documented that the styling will be lost when both settings for
ServerReport/ServerInfo are set to false... eg by adding this to server.xml:

<Valve className="org.apache.catalina.valves.ErrorReportValve"
showReport=false" showServerInfo="false" />

(and I confirmed this recently)

from looking at the source for ErrorReportValve   for tomcat 7.0.78 it
LOOKS like this would be easy to fix:
(however, I'm neither a tomcat/java/HTML or CSS expert, so there may be
very good reasons this is done this way):

currently:

        StringBuilder sb = new StringBuilder();

        sb.append("<html><head>");
        if(showServerInfo || showReport){
            sb.append("<title>");
            if(showServerInfo) {
                sb.append(ServerInfo.getServerInfo()).append(" - ");
            }
            sb.append(smClient.getString("errorReportValve.errorReport"));
            sb.append("</title>");
            sb.append("<style><!--");
            sb.append(org.apache.catalina.util.TomcatCSS.TOMCAT_CSS);
            sb.append("--></style> ");
        } else {
            sb.append("<title>");
            sb.append(smClient.getString("errorReportValve.errorReport"));
            sb.append("</title>");
        }
        sb.append("</head><body>");

.... it looks to me like simply moving the three lines for style/css/style
outside the If statement would fix this, like so:

        StringBuilder sb = new StringBuilder();

        sb.append("<html><head>");
        if(showServerInfo || showReport){
            sb.append("<title>");
            if(showServerInfo) {
                sb.append(ServerInfo.getServerInfo()).append(" - ");
            }
            sb.append(smClient.getString("errorReportValve.errorReport"));
            sb.append("</title>");
        } else {
            sb.append("<title>");
            sb.append(smClient.getString("errorReportValve.errorReport"));
            sb.append("</title>");
        }
        // move style lines outside of if(showServerInfo || showReport){
section... above
        sb.append("<style><!--");
        sb.append(org.apache.catalina.util.TomcatCSS.TOMCAT_CSS);
        sb.append("--></style> ");
        sb.append("</head><body>");
...

or am I missing (or just ignorant of ) something?

John Palmer

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message