You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by bu...@apache.org on 2003/02/19 19:12:29 UTC
DO NOT REPLY [Bug 17211] New: -
FIX: Tomcat 4.1.x taglib pooling causes problems
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17211>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17211
FIX: Tomcat 4.1.x taglib pooling causes problems
Summary: FIX: Tomcat 4.1.x taglib pooling causes problems
Product: Taglibs
Version: 1.1
Platform: Other
OS/Version: Other
Status: NEW
Severity: Blocker
Priority: Other
Component: XTags Taglib
AssignedTo: taglibs-dev@jakarta.apache.org
ReportedBy: esuastegui@quest.com
I am running Tomcat 4.1.18 with JDK 1.4.1.01, and use the xtags library for
server-side XSL transformation (XSLT). The first time I access the page that
includes XML to be displayed through xtags' XSLT, it works. The 2nd time, it
fails (see exception stack trace below), the 3rd time it works, the 4th time
it fails, and so on--odds are okay; evens fail. I do not have this problem
with either Tomcat 4.0.3 or 4.0.6; when I switch to these versions, all
works as expected. I have also tried disabling taglibs pooling in the
web.xml for 4.1.18, and though that works, it is a work-around, so I offer the
following fix.
With thanks to David Spencer for pointing me in the right direction, I would
like to submit the following fix to
org.apache.taglibs.xtags.xslt.StyleTag.java. I only list code that has
changed from the source base (which I downloaded 3 days ago).
/** Perform the transformation and render the output.
*
* @exception JspException if a JSP exception occurs
*/
public int doEndTag() throws JspException {
if ( xml == null || xsl == null ) {
throw new JspException( "Must specify both XML and an XSLT to
style" );
}
// Prepare an input source for the data
System.out.print("XML: ");
Source data = getSource(xml);
// Prepare an input source for the stylesheet
System.out.print("XSL: ");
Source style = getSource(xsl);
// Prepare an output source for the outputs
Result result = getResult();
// Use JAXP to perform the stylesheet
try {
TransformerFactory factory = TransformerFactory.newInstance();
factory.setURIResolver( createURIResolver() );
Transformer transformer = factory.newTransformer(style);
configure(transformer);
transformer.transform( data, result );
if ( stringWriter != null ) {
pageContext.getOut().write( stringWriter.toString() );
}
}
catch (TransformerException e) {
handleException(e);
}
catch (IOException e) {
handleException(e);
}
finally {
stringWriter = null;
// Release state to help out with Tomcat 4.1.18:
cleanUp();
}
return EVAL_PAGE;
}
/**
* Since Tomcat 4.1.18 uses taglibs pooling, we must clean up (release
* state) after doEndTag().
* E. Suastegui -- 02/14/03
*/
private void cleanUp()
{
xml = null;
xsl = null;
result = null;
parameters = null;
}
/**
* Release any allocated resources.
*/
public void release() {
cleanUp();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org