DOM classes and thread safety

From: campus (camporeale_at_hotmail.com)
Date: 08/26/04


Date: 26 Aug 2004 09:14:06 -0700

Hi
I've this problem: I've found on
http://xml.apache.org/xerces2-j/faq-dom.html#faq-1
that DOM access is not thread safe!

I've written a class (not static) with a method containing a code like
this:

import org.w3c.dom.*;
import org.apache.xerces.*;
import org.apache.xerces.dom.*;
import org.apache.xerces.parsers.*;
import org.apache.xml.serialize.*;

      //create the document object from the string of message
      DOMParser parser = new DOMParser();
      parser.parse(new InputSource(new StringReader(msg)));
      XMLDocument = parser.getDocument();
      //set the element root fo the document
      rootElement = XMLDocument.getDocumentElement();
      ....
      ....
      node.getFirstChild().getNodeValue();
      .....
      ....

This class is instantiated inside a jsp and here some methods of this
class are called.
Because the jsp is translated into a servlet and the code written in
the jsp is executed by the servlet
in a thread inside the JVM of the application server, I conclude that
my class is executed in a thread.

I didn't put any "syncronize" anywhere. Have I to worry about that?

Thanks in advance for your answers.
Bye



Relevant Pages

  • DOM classes and thread safety
    ... that DOM access is not thread safe! ... This class is instantiated inside a jsp and here some methods of this ... the jsp is executed by the servlet ...
    (comp.lang.java.programmer)
  • Re: [OT] Which technology might I use for this web application?
    ... Can I write the server code in Java? ... output-rich purposes, Java Server Pages (JSP) is a useful technology that runs on top of servlets. ... Apache Tomcat is a popular, capable servlet container; some other containers include IBM Websphere and Bea WebLogic, and there are others. ... Some tag libraries include JSP custom tags for performing DB accesses, or you can do it directly in your own Java code. ...
    (comp.lang.java.programmer)
  • More info...anyone up for a challenge?
    ... Incase anyone is really up for a challenge on this one, ... Basically we have a frameset with date headers, nav bar etc, and the main ... content frame contains a jsp that onLoad, ... If we use the Favorites link, the log shows a GET was issued to the servlet, ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: what is the MVC all about
    ... WIth a JSP you can call any Java class/method directly from a ... so the JSP gets control first. ... just do this instead:) If a Servlet gets control first (specified by ... The Servlet didn't generate HTML, ...
    (comp.lang.perl.misc)
  • Re: Fortschrittsanzeige mit Servlets bzw. JSP
    ... welche die Aktion startet wird an ein Servlet geschickt. ... Servlet macht ein Forward auf eine JSP, wobei der aktuelle Fortschritt ... Next by Date: ...
    (de.comp.lang.java)