tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ben Boule" <>
Subject Bugzilla # 15337 question
Date Fri, 21 May 2004 20:04:06 GMT

I downloaded 5.0.19 a few weeks ago, and am trying to get our application
running on Tomcat 5 to see if the performance will be a worthwhile upgrade
over Tomcat 4.

I am seeing ArrayOutOfBoundsExceptions in the JspReader class for several of
our files.  All of these files are single line files which do not appear to
have a newline at the end of the file.  These work correctly in Tomcat 4.
Apparently it is desirable to leave them with no newline at the end of the
file because they are used to generate titles for the HTML pages, and we
didn't want newlines in the titles in the HTML.

I have not been able to determine if it is actually legal to have a JSP file
with no newline at the end of the file.

Looking at JspReader the problem appears to occur in JspReader::skipUntil
which starts at line 308 of the file

Unfortunately I don't have the stack trace.  The exception was occurring at
the line that calls peekChar() though.

I added some code to catch the exception and try to deal with it, and it
appears to work although I don't completely understand the underlying code.

Here is my modified method:

Mark skipUntil(String limit) throws JasperException {
      Mark ret = null;
	int limlen = limit.length();
	int ch;

      for (ret = mark(), ch = nextChar() ; ch != -1 ;\
           ret = mark(), ch = nextChar()) {
	 	if (ch == limit.charAt(0)) {
 		    Mark restart = mark();
 		    for (int i = 1 ; i < limlen ; i++) {
 			try {
			    if (peekChar() == limit.charAt(i))          <--- Exception occurs
			    else {
 				continue skip;
 			} catch (ArrayIndexOutOfBoundsException e) {
			    System.err.println("JspReader::skipUntil -
			    System.err.println("Limit param: \""+limit+"\"");
			    System.err.println("loop index: "+i);
			    System.err.println("Resetting stream, continuing to skip label.");
			    continue skip;
            return ret;
     return null;

Bugzilla # 15377 is the only similar lead I could find by searching the web,
however it doesn't seem to fix this particular problem and/or the fix was
made a long time ago and was lost in a fork.  (The bug is marked December

I'm not sure if my addition is correct, or if the correct answer is that the
JSP files must be changed.   However it would seem obvious that if the JSP
files need to be changed, the compiler needs to report the file as an error,
rather than crashing the compiler.

I would like to figure out who is the appropriate person to discuss this
with, and what I should do.  In the meantime I'll go forward with our
evaluation with this little patch in place.

I guess the best answer would be if I was told this is fixed in 5.0.24 or
something like that, but I don't see anything in the changelogs.

Thank you,
Ben Boule

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message