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 kalyanaraman <sk...@bsil.com> on 2004/02/12 19:05:42 UTC

Releasing held resources in XTags StyleTag

Dear Developer,

I have downloaded the latest files from the jakarta-taglibs and tried using
XTAGS.
 My tomcat version is 4.1.29 on Microsoft Windows 2000 (Professional). I
have run into a probelm
 using the style tag of XTags library. The page was working well when I
loaded it for the
 first time but when I tried refreshing the same page it was throwing me the
following exception

	 java.io.IOException: Stream closed

What I found from the source code is that, probably the xml/xsl resources
are not released in the doEndTag() method in
	org.apache.taglibs.xtags.xslt.StyleTag.java file.I tried releasing the
resources held as shown below and it works without errors.

    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
        Source data = getSource(xml);

        // Prepare an input source for the stylesheet
        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 all the held resources
            release();
        }
	return EVAL_PAGE;
    }


It would be great if you can make this change and help us in getting this
bug fixed in the forecoming build.


Thanks in advance,
Sri Kalyanaraman.K
eSuite Team,
BLUE STAR INFOTECH LTD.,
Bangalore
India.
Tel: (91)(80)51104560/61 Extn-2732
Email: skalyanaraman@bsil.com


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org


Re: Releasing held resources in XTags StyleTag

Posted by Kris Schneider <kr...@dotech.com>.
This doesn't address you concern with XTags, but you may want to look into
moving to Standard (JSTL). You'll want the latest 1.0 version (currently 1.0.5)
and the equivalent tag is <x:transform>.

Quoting kalyanaraman <sk...@bsil.com>:

> 
> Dear Developer,
> 
> I have downloaded the latest files from the jakarta-taglibs and tried using
> XTAGS.
>  My tomcat version is 4.1.29 on Microsoft Windows 2000 (Professional). I
> have run into a probelm
>  using the style tag of XTags library. The page was working well when I
> loaded it for the
>  first time but when I tried refreshing the same page it was throwing me
> the
> following exception
> 
> 	 java.io.IOException: Stream closed
> 
> What I found from the source code is that, probably the xml/xsl resources
> are not released in the doEndTag() method in
> 	org.apache.taglibs.xtags.xslt.StyleTag.java file.I tried releasing the
> resources held as shown below and it works without errors.
> 
>     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
>         Source data = getSource(xml);
> 
>         // Prepare an input source for the stylesheet
>         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 all the held resources
>             release();
>         }
> 	return EVAL_PAGE;
>     }
> 
> 
> It would be great if you can make this change and help us in getting this
> bug fixed in the forecoming build.
> 
> 
> Thanks in advance,
> Sri Kalyanaraman.K
> eSuite Team,
> BLUE STAR INFOTECH LTD.,
> Bangalore
> India.
> Tel: (91)(80)51104560/61 Extn-2732
> Email: skalyanaraman@bsil.com

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org