views:

162

answers:

1

All, I'm working on a java webapp that we deploy in the Resin web app server. I have been doing some XML parsing for a new part of the application, and realized that our app was using Resin classes to do the parsing. I wanted to get away from that and use something more standard for a number of reasons, so I set these system properties in my resin config file (and added the xerces jar to my classpath):

<system-property javax.xml.parsers.DocumentBuilderFactory="org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"/>

<system-property javax.xml.parsers.SAXParserFactory="org.apache.xerces.jaxp.SAXParserFactoryImpl"/>

And, now I'm getting JSP compilation errors on several pages (I guess Resin's built in parser was more lenient). The error reads:

org.xml.sax.SAXParseException: The value of attribute "title" associated with an element type "display:column" must not contain the '<' character.

And, the 'display:column' tag on some pages does indeed contain markup in the 'title' attribute. Here's an example:

<display:column scope='col' class=" appealColorBG  selectAllWidth" 
    title="<span class='centerThis'><label for='selectAll'>Select All</label><br />
            <input type='checkbox' name='selectAll' 
            id='selectAll' 
            onClick='selectAllCheckboxes();'/></span> " >

That's some ugly JSP code, I know, but it's also code that's already in production, so I'm hesitant to change it.

Does anyone know of a way that I can set xerces so that it will allow the JSP to compile as is?

+1  A: 

That's certainly ugly JSP code.

If you're using an XML parser on it, you've got a problem. Attribute values in valid XML can not contain the '<' character, as Xerces is telling you.

It's doubtful you can tell Xerces to accept this, but fixing the XML would be a better idea than talking an XML parser into accepting incorrect XML anyway.

You probably want to drop back to using the Resin classes until you can feed Xerces proper XML, or configure Resin to not use an XML parser as part of its JSP compilation - see comments.

Don Roby
Yeah, Resin seems to be running the JSPs through the parser before compiling - maybe that's standard, but I didn't realize it. As you say, it may not be possible, but that's what I wanted to ask :) It's not an option for me to change the JSPs, since this is a rather large existing codebase, so I may have to live with the Resin classes.
elduff
Just poked through Resin docs a bit, and I suspect you can tell Resin not to treat JSP as XML. Have a look at http://www.caucho.com/resin-3.0/config/webapp.xtp#jsp for hints on this. It looks like it should be the default though.
Don Roby
@donroby - Thanks for the link to the resin docs with the jsp config tag - I did play around with those a bit, but am still always getting that JSP compilation error. It does look like I'm going to have to go back to the resin parser for now. thanks for the help!
elduff