*/
private boolean xpoweredBy;
+ /**
+ * Should we include a source fragment in exception messages, which could be displayed
+ * to the developer ?
+ */
+ private boolean displaySourceFragment = true;
+
+
public String getProperty(String name ) {
return settings.getProperty( name );
}
}
/**
+ * Should we include a source fragment in exception messages, which could be displayed
+ * to the developer ?
+ */
+ public boolean getDisplaySourceFragment() {
+ return displaySourceFragment;
+ }
+
+ /**
* Create an EmbeddedServletOptions object using data available from
* ServletConfig and ServletContext.
*/
}
}
+ String displaySourceFragment = config.getInitParameter("displaySourceFragment");
+ if (displaySourceFragment != null) {
+ if (displaySourceFragment.equalsIgnoreCase("true")) {
+ this.displaySourceFragment = true;
+ } else if (displaySourceFragment.equalsIgnoreCase("false")) {
+ this.displaySourceFragment = false;
+ } else {
+ if (log.isWarnEnabled()) {
+ log.warn(Localizer.getMessage("jsp.warning.displaySourceFragment"));
+ }
+ }
+ }
+
// Setup the global Tag Libraries location cache for this
// web-application.
tldLocationsCache = new TldLocationsCache(context);
jsp.warning.dumpSmap=Warning: Invalid value for the initParam dumpSmap. Will use the default value of \"false\"
jsp.warning.genchararray=Warning: Invalid value for the initParam genStrAsCharArray. Will use the default value of \"false\"
jsp.warning.suppressSmap=Warning: Invalid value for the initParam suppressSmap. Will use the default value of \"false\"
+jsp.warning.displaySourceFragment=Warning: Invalid value for the initParam displaySourceFragment. Will use the default value of \"true\"
jsp.error.badtaglib=Unable to open taglibrary {0} : {1}
jsp.error.badGetReader=Cannot create a reader when the stream is not buffered
jsp.warning.unknown.element.in.taglib=Unknown element ({0}) in taglib
jsp.error.invalid.bean=The value for the useBean class attribute {0} is invalid.
jsp.error.prefix.use_before_dcl=The prefix {0} specified in this tag directive has been previously used by an action in file {1} line {2}.
+jsp.exception=An exception occurred processing JSP page {0} at line {1}
+
# JSP 2.1
jsp.error.el.template.deferred=#{..} is not allowed in template text
jsp.error.el.parse={0} : {1}
throw new JasperException(ex);
}
- // Read both files in, so we can inspect them
- String[] jspLines = readFile
+ if (options.getDisplaySourceFragment()) {
+
+ // Read both files in, so we can inspect them
+ String[] jspLines = readFile
(this.ctxt.getResourceAsStream(this.ctxt.getJspFile()));
- String[] javaLines = readFile
+ String[] javaLines = readFile
(new FileInputStream(this.ctxt.getServletJavaFileName()));
- // If the line contains the opening of a multi-line scriptlet
- // block, then the JSP line number we got back is probably
- // faulty. Scan forward to match the java line...
- if (jspLines[jspLineNumber-1].lastIndexOf("<%") >
+ // If the line contains the opening of a multi-line scriptlet
+ // block, then the JSP line number we got back is probably
+ // faulty. Scan forward to match the java line...
+ if (jspLines[jspLineNumber-1].lastIndexOf("<%") >
jspLines[jspLineNumber-1].lastIndexOf("%>")) {
- String javaLine = javaLines[javaLineNumber-1].trim();
+ String javaLine = javaLines[javaLineNumber-1].trim();
- for (int i=jspLineNumber-1; i<jspLines.length; i++) {
- if (jspLines[i].indexOf(javaLine) != -1) {
- jspLineNumber = i+1;
- break;
+ for (int i=jspLineNumber-1; i<jspLines.length; i++) {
+ if (jspLines[i].indexOf(javaLine) != -1) {
+ jspLineNumber = i+1;
+ break;
+ }
}
}
- }
- // copy out a fragment of JSP to display to the user
- StringBuffer buffer = new StringBuffer(1024);
- int startIndex = Math.max(0, jspLineNumber-1-3);
- int endIndex = Math.min(jspLines.length-1, jspLineNumber-1+3);
+ // copy out a fragment of JSP to display to the user
+ StringBuffer buffer = new StringBuffer(1024);
+ int startIndex = Math.max(0, jspLineNumber-1-3);
+ int endIndex = Math.min(jspLines.length-1, jspLineNumber-1+3);
- for (int i=startIndex;i<=endIndex; ++i) {
- buffer.append(i+1);
- buffer.append(": ");
- buffer.append(jspLines[i]);
- buffer.append("\n");
- }
+ for (int i=startIndex;i<=endIndex; ++i) {
+ buffer.append(i+1);
+ buffer.append(": ");
+ buffer.append(jspLines[i]);
+ buffer.append("\n");
+ }
- return new JasperException(
- "Exception in JSP: " + detail.getJspFileName() + ":" +
- jspLineNumber + "\n\n" + buffer + "\n\nStacktrace:", ex);
+ return new JasperException(Localizer.getMessage
+ ("jsp.exception", detail.getJspFileName(), "" + jspLineNumber) + "\n" + buffer, ex);
+
+ } else {
+ return new JasperException(Localizer.getMessage
+ ("jsp.exception", detail.getJspFileName(), "" + jspLineNumber), ex);
+ }
}
} catch (Exception je) {
// If anything goes wrong, just revert to the original behaviour