hart,  pool the instance's and make the get from the pool thread safe. 

vasanth
ct-usa
-----Original Message-----
From: Cameron Hart [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 20, 2003 1:47 PM
To: [EMAIL PROTECTED]
Subject: Re: Xerces-2 DOMParser bottleneck


Is it okay to make DocumentBuilder and DocumentBuilderFactory static? I 
was put off by the docs that said they weren't guaranteed to be thread 
safe, "An implementation of DocumentBuilder is NOT guaranteed to behave 
as per the specification if it is used concurrently by two or more threads."

Soosai, Lourdhu Vasanth wrote:
> hi hart,
>       put ur code inside jsp declaration with static instances.
>       <!%
>               private static DocumentBuilderFactory dbf =
> DocumentBuilderFactory.newInstance(); 
>               private static DocumentBuilder db =
> dbf.newDocumentBuilder();
>               private static XHTMLSerializer xs = new XHTMLSerializer();
>                   private static
> xs.setOutputByteStream(response.getOutputStream());
>       // u can write a ServiceHelper class which returns a instance off
> the above.    
>       // u can catch the docBuilder alone as well.
>       %>
>       <%
>               for(int i=0;i<myLength;i++)
>               {
>       
>               InputSource inputSource = new
>
InputSource(getServletConfig().getServletContext().getResourceAsStream("inde
> x.html"));
>                   doc = db.parse(inputSource);
>               //flush out
>                xs.serialize(doc);
> 
>               }
> 
>       %>
>  hope this helps
> 
>   vasanth
>   ct-usa              
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

This e-mail may contain confidential or privileged information.  If you
think you have received this e-mail in error, please advise the sender by
reply e-mail and then delete this e-mail immediately.  Thank you.  Aetna

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to