tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <>
Subject Re: TC 7.0.16 IllegalStateException thrown by pageContext.include
Date Fri, 24 Jun 2011 11:01:51 GMT
2011/6/24 David Wall <>:
>>> out.write("<script type=\"text/javascript\">\n");
>>> pageContext.include("/static/esf/esf.js",true);
>>> out.write("</script>\n");
>>> But the exception IllegalStateException is thrown on the include of the
>>> esf.js file.  The reason is null, so there's no more details.  I find it odd
>>> in that the two prior includes works okay, but that third one fails.  The
>>> file is definitely there (and has been working under TC 6.0 before).
>> When I change the code to use /static/esf/esf.javascript and rename the
>> file to have the same suffix, the exception is not thrown.
>> Is there anything special about the .js suffix on a file for
>> pageContext.include()?
> Okay, I learned that this is because web.xml for TC 6 uses:
> <mime-mapping>
> <extension>js</extension>
> <mime-type>text/javascript</mime-type>
> </mime-mapping>
> But TC 7 uses:
> <mime-mapping>
> <extension>js</extension>
> <mime-type>application/javascript</mime-type>
> </mime-mapping>
> If I put the old TC 6 version in my app's web.xml, then it works again.

Is there stacktrace for the IllegalStateException that you were observing?

> Question: Is this to be expected?  Is TC 7 doing the "right thing" here?  Am
> I breaking something when I update my app's web.xml to say it's 'text'
> again?

I think (without further looking) that the problem is the following:

The static file (the .js) is served by DefaultServlet.  For
DefaultServlet the data are opaque, so it should be served using an

In your case, 'out' is a Writer. Trying to open OutputStream after a
Writer has been opened is not allowed.

IIRC, there was some workaround in DefaultServlet for the mime types
that are text/*. I wonder maybe that can be made to work in your case.

The underlying problem though is that to include data from the file
into the writer, one has to convert bytes -> chars,  and for that one
has to know the textual encoding of the file.

Where one can get the encoding?

Best regards,
Konstantin Kolinko

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

View raw message