You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by "Julien, Timothy" <TJ...@Bluestone.com> on 2001/03/21 22:20:17 UTC

bug in Jasper - bad calls to Constants.getString

I believe there is a bug in Jasper when resources (such as web.xml's dtd)
can't be loaded.
The basic problem is that keys are getting passed into Constants.getString()
which aren't keys in the message resources file.  This happens because of
some exception handling, which basically constructs an invalid key - namely,
a *value* in the message resources file.

JspUtil.parseXMLDocJaxp(String, InputStream)
{
	try
	{
		...
	}
	catch(IOException io)
      {
            throw new
JasperException(Constants.getString("jsp.error.parse.xml", new Object[] {
                uri, io.toString()
            }));
      }
}
and then lower down the call stack:

public TldLocationsCache(ServletContext ctxt)
{
     mappings = new Hashtable();
     try
     {
         processWebDotXml(ctxt);
         processJars(ctxt);
     }
     catch(JasperException ex)
     {
         Constants.message(ex.getMessage(), 1);
     }
}

The trouble is that ex.getMessage() here contains a *value* from the message
resource file, (as looked up in the first caught Exception) not a *key*.

One fix would be in JspUtil.parseXMLDocJaxp(String, InputStream) to pass
only the key (jsp.error.parse.xml) as the JasperException's message - and
delay the lookup.  But then you lose some information (i.e., io.String()).

Maybe a better solution is to set a flag on JasperException which marks its
message as being either key or value - so that Constants.getString can be
called only when necessary.  I realize this would effect alot of code.

anyway, I'm happy to help in any way with the fix.
Tim Julien
HP Middleware