View | Details | Raw Unified | Return to bug 42314
Collapse All | Expand All

(-)src/share/org/apache/jasper/compiler/DefaultErrorHandler.java (+11 lines)
Lines 79-84 Link Here
79
                buf.append(details[i].getErrorMessage());
79
                buf.append(details[i].getErrorMessage());
80
                buf.append("\n"); 
80
                buf.append("\n"); 
81
                buf.append(details[i].getJspExtract());
81
                buf.append(details[i].getJspExtract());
82
            } else if (details[i].getJavaLineNumber() >= 0) {
83
                args = new Object[] {
84
                        new Integer(details[i].getJavaLineNumber()), 
85
                        details[i].getJavaFileName()};
86
                buf.append("\n");
87
                buf.append(Localizer.getMessage("jsp.error.single.line.number.servlet",
88
                        args));
89
                buf.append("\n"); 
90
                buf.append(details[i].getErrorMessage());
91
                buf.append("\n"); 
92
                buf.append(details[i].getJspExtract());
82
            }
93
            }
83
        }
94
        }
84
        buf.append("\n\nStacktrace:");
95
        buf.append("\n\nStacktrace:");
(-)src/share/org/apache/jasper/compiler/JavacErrorDetail.java (-31 / +52 lines)
Lines 18-23 Link Here
18
package org.apache.jasper.compiler;
18
package org.apache.jasper.compiler;
19
19
20
import java.io.BufferedReader;
20
import java.io.BufferedReader;
21
import java.io.File;
21
import java.io.FileInputStream;
22
import java.io.FileInputStream;
22
import java.io.IOException;
23
import java.io.IOException;
23
import java.io.InputStream;
24
import java.io.InputStream;
Lines 54-63 Link Here
54
                            int javaLineNum,
55
                            int javaLineNum,
55
                            StringBuffer errMsg) {
56
                            StringBuffer errMsg) {
56
57
57
        this.javaFileName = javaFileName;
58
        this(javaFileName, javaLineNum, null, -1, errMsg);
58
        this.javaLineNum = javaLineNum;
59
        this.errMsg = errMsg;
60
        this.jspBeginLineNum = -1;
61
    }
59
    }
62
60
63
    /**
61
    /**
Lines 88-106 Link Here
88
            int jspBeginLineNum,
86
            int jspBeginLineNum,
89
            StringBuffer errMsg,
87
            StringBuffer errMsg,
90
            JspCompilationContext ctxt) {
88
            JspCompilationContext ctxt) {
91
        this(javaFileName, javaLineNum, errMsg);
89
        this.javaFileName = javaFileName;
90
        this.javaLineNum = javaLineNum;
92
        this.jspFileName = jspFileName;
91
        this.jspFileName = jspFileName;
92
        this.errMsg = errMsg;
93
        this.jspBeginLineNum = jspBeginLineNum;
93
        this.jspBeginLineNum = jspBeginLineNum;
94
        
94
95
        if (jspBeginLineNum > 0 && ctxt != null) {
95
        int beginLineNum = 0;
96
            try {
96
        String[] sourceLines = null;
97
        InputStream javaStream = null;
98
        InputStream jspStream = null;
99
100
        try {
101
            // To display canonical path at DefaultErrorHandler.
102
            this.javaFileName = (new File(javaFileName)).getCanonicalPath();
103
            javaStream = new FileInputStream(this.javaFileName);
104
            String[] javaLines = readFile(javaStream);
105
106
            if (jspBeginLineNum > 0 && ctxt != null) {
97
                // Read both files in, so we can inspect them
107
                // Read both files in, so we can inspect them
98
                String[] jspLines = readFile
108
                jspStream = ctxt.getResourceAsStream(jspFileName);
99
                    (ctxt.getResourceAsStream(jspFileName));
109
                String[] jspLines = readFile(jspStream);
100
    
110
    
101
                String[] javaLines = readFile
102
                    (new FileInputStream(ctxt.getServletJavaFileName()));
103
    
104
                // If the line contains the opening of a multi-line scriptlet
111
                // If the line contains the opening of a multi-line scriptlet
105
                // block, then the JSP line number we got back is probably
112
                // block, then the JSP line number we got back is probably
106
                // faulty.  Scan forward to match the java line...
113
                // faulty.  Scan forward to match the java line...
Lines 116-141 Link Here
116
                        }
123
                        }
117
                    }
124
                    }
118
                }
125
                }
119
    
126
                beginLineNum = this.jspBeginLineNum;
120
                // copy out a fragment of JSP to display to the user
127
                sourceLines = jspLines;
121
                StringBuffer fragment = new StringBuffer(1024);
128
            } else {
122
                int startIndex = Math.max(0, this.jspBeginLineNum-1-3);
129
                beginLineNum = javaLineNum;
123
                int endIndex = Math.min(
130
                sourceLines = javaLines;
124
                        jspLines.length-1, this.jspBeginLineNum-1+3);
125
    
126
                for (int i=startIndex;i<=endIndex; ++i) {
127
                    fragment.append(i+1);
128
                    fragment.append(": ");
129
                    fragment.append(jspLines[i]);
130
                    fragment.append("\n");
131
                }
132
                jspExtract = fragment.toString();
133
    
134
            } catch (IOException ioe) {
135
                // Can't read files - ignore
136
            }
131
            }
132
133
            // copy out a fragment of JSP to display to the user
134
            StringBuffer fragment = new StringBuffer(1024);
135
            int startIndex = Math.max(0, beginLineNum-1-3);
136
            int endIndex = Math.min(sourceLines.length-1, beginLineNum-1+3);
137
138
            for (int i=startIndex;i<=endIndex; ++i) {
139
                fragment.append(i+1);
140
                fragment.append(": ");
141
                fragment.append(sourceLines[i]);
142
                fragment.append("\n");
143
            }
144
            jspExtract = fragment.toString();
145
146
        } catch (IOException ioe) {
147
            // Can't read files - ignore
148
        } finally{
149
            if (javaStream != null){
150
                try {
151
                    javaStream.close();
152
                } catch (IOException e) {}
153
            }
154
            if (jspStream != null){
155
                try {
156
                    jspStream.close();
157
                } catch (IOException e) {}
158
            }
137
        }
159
        }
138
139
    }
160
    }
140
    /**
161
    /**
141
     * Gets the name of the Java source file in which the compilation error
162
     * Gets the name of the Java source file in which the compilation error
(-)src/share/org/apache/jasper/resources/LocalStrings.properties (+1 lines)
Lines 300-305 Link Here
300
jsp.error.needAlternateJavaEncoding=Default java encoding {0} is invalid on your java platform. An alternate can be specified via the 'javaEncoding' parameter of JspServlet.
300
jsp.error.needAlternateJavaEncoding=Default java encoding {0} is invalid on your java platform. An alternate can be specified via the 'javaEncoding' parameter of JspServlet.
301
#Error when compiling, used for jsp line number error messages
301
#Error when compiling, used for jsp line number error messages
302
jsp.error.single.line.number=An error occurred at line: {0} in the jsp file: {1}
302
jsp.error.single.line.number=An error occurred at line: {0} in the jsp file: {1}
303
jsp.error.single.line.number.servlet=An error occurred at line: {0} in the generated servlet: {1}
303
jsp.error.multiple.line.number=\n\nAn error occurred between lines: {0} and {1} in the jsp file: {2}\n\n
304
jsp.error.multiple.line.number=\n\nAn error occurred between lines: {0} and {1} in the jsp file: {2}\n\n
304
jsp.error.corresponding.servlet=Generated servlet error:\n
305
jsp.error.corresponding.servlet=Generated servlet error:\n
305
jsp.error.empty.body.not.allowed=Empty body not allowed for {0}
306
jsp.error.empty.body.not.allowed=Empty body not allowed for {0}
(-)src/share/org/apache/jasper/resources/LocalStrings_ja.properties (+2 lines)
Lines 294-299 Link Here
294
jsp.error.needAlternateJavaEncoding=\u30c7\u30d5\u30a9\u30eb\u30c8\u306eJava\u30a8\u30f3\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0 {0} \u306f\u3042\u306a\u305f\u306e\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u3067\u306f\u7121\u52b9\u3067\u3059\u3002JspServlet\u306e 'javaEncoding' \u30d1\u30e9\u30e1\u30bf\u3067\u3001\u5225\u306e\u5024\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002
294
jsp.error.needAlternateJavaEncoding=\u30c7\u30d5\u30a9\u30eb\u30c8\u306eJava\u30a8\u30f3\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0 {0} \u306f\u3042\u306a\u305f\u306e\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u3067\u306f\u7121\u52b9\u3067\u3059\u3002JspServlet\u306e 'javaEncoding' \u30d1\u30e9\u30e1\u30bf\u3067\u3001\u5225\u306e\u5024\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002
295
#Error when compiling, used for jsp line number error messages
295
#Error when compiling, used for jsp line number error messages
296
jsp.error.single.line.number=JSP\u30d5\u30a1\u30a4\u30eb: {1} \u306e\u4e2d\u306e{0}\u884c\u76ee\u3067\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f
296
jsp.error.single.line.number=JSP\u30d5\u30a1\u30a4\u30eb: {1} \u306e\u4e2d\u306e{0}\u884c\u76ee\u3067\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f
297
jsp.error.single.line.number.servlet=\u751f\u6210\u3055\u308c\u305f\u30b5\u30fc\u30d6\u30ec\u30c3\u30c8: {1} \u306e\u4e2d\u306e{0}\u884c\u76ee\u3067\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f
297
jsp.error.multiple.line.number=\n\nJPS\u30d5\u30a1\u30a4\u30eb: {2}\u306e\u4e2d\u306e{0}\u884c\u76ee\u3068{1}\u884c\u76ee\u306e\u9593\u3067\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\n\n
298
jsp.error.multiple.line.number=\n\nJPS\u30d5\u30a1\u30a4\u30eb: {2}\u306e\u4e2d\u306e{0}\u884c\u76ee\u3068{1}\u884c\u76ee\u306e\u9593\u3067\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\n\n
298
jsp.error.corresponding.servlet=\u751f\u6210\u3055\u308c\u305f\u30b5\u30fc\u30d6\u30ec\u30c3\u30c8\u306e\u30a8\u30e9\u30fc\u3067\u3059:\n
299
jsp.error.corresponding.servlet=\u751f\u6210\u3055\u308c\u305f\u30b5\u30fc\u30d6\u30ec\u30c3\u30c8\u306e\u30a8\u30e9\u30fc\u3067\u3059:\n
299
jsp.error.empty.body.not.allowed={0} \u306b\u5bfe\u3057\u3066\u7a7a\u306e\u30dc\u30c7\u30a3\u306f\u8a31\u3055\u308c\u307e\u305b\u3093
300
jsp.error.empty.body.not.allowed={0} \u306b\u5bfe\u3057\u3066\u7a7a\u306e\u30dc\u30c7\u30a3\u306f\u8a31\u3055\u308c\u307e\u305b\u3093
Lines 405-407 Link Here
405
jsp.error.invalid.bean=useBean\u306e\u30af\u30e9\u30b9\u5c5e\u6027 {0} \u306e\u5024\u304c\u7121\u52b9\u3067\u3059
406
jsp.error.invalid.bean=useBean\u306e\u30af\u30e9\u30b9\u5c5e\u6027 {0} \u306e\u5024\u304c\u7121\u52b9\u3067\u3059
406
jsp.error.prefix.use_before_dcl=\u3053\u306e\u30bf\u30b0\u6307\u793a\u5b50\u3067\u6307\u5b9a\u3055\u308c\u3066\u3044\u308b\u30d7\u30ea\u30d5\u30a3\u30c3\u30af\u30b9 {0} \u306f\u3001\u3059\u3067\u306b\u30d5\u30a1\u30a4\u30eb {1} \u306e {2} \u884c\u76ee\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u3067\u4f7f\u7528\u3055\u308c\u3066\u3044\u307e\u3059
407
jsp.error.prefix.use_before_dcl=\u3053\u306e\u30bf\u30b0\u6307\u793a\u5b50\u3067\u6307\u5b9a\u3055\u308c\u3066\u3044\u308b\u30d7\u30ea\u30d5\u30a3\u30c3\u30af\u30b9 {0} \u306f\u3001\u3059\u3067\u306b\u30d5\u30a1\u30a4\u30eb {1} \u306e {2} \u884c\u76ee\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u3067\u4f7f\u7528\u3055\u308c\u3066\u3044\u307e\u3059
407
408
409

Return to bug 42314