Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2011
    Posts
    62
    Rep Power
    0

    Default DOM model and JavaBeans

    In a JSP website, JavaBeans are normally used as an intermediate step between the requested data base data and the display. In other words, each requested data set is packed into a bean and the bean data is then read and displayed.

    But what about XML data that is already stored in a DOM tree? Do I also need beans here or could I directly read the data from the DOM tree to display it?

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,087
    Rep Power
    20

    Default Re: DOM model and JavaBeans

    If displaying it would involve sticking code into the JSP then I'd say process it first for the data you want.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    Join Date
    Aug 2011
    Posts
    62
    Rep Power
    0

    Default Re: DOM model and JavaBeans

    I just want to know why a DOM tree has to be kept in memory, even though I only want to read the data and not manipulate it. Isn't a streaming parser a better choice in this scenario?

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,087
    Rep Power
    20

    Default Re: DOM model and JavaBeans

    I don't know the scenario, so I can't really say.
    Your question presupposed a DOM tree already in memory.
    I wouldn't, personally, keep a DOM in memory for long if it was of any significant size (the value of which may vary depending on circumstances). To be honest in those cases it would be unwrapped into objects anyway.
    I'm trying to think of a case where I have seen it done, but beyond some form of properties xml (which are converted to something easier to handle) I can't think of one.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    Join Date
    Aug 2011
    Posts
    62
    Rep Power
    0

    Default Re: DOM model and JavaBeans

    Thanks. In my case, read-only bean objects are created from the XML right upon application start, so it wouldn't make much sense to keep the DOM model in memory.

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,087
    Rep Power
    20

    Default Re: DOM model and JavaBeans

    OK.
    I'm a bit lost now as to what you're actually asking...
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  7. #7
    Join Date
    Aug 2011
    Posts
    62
    Rep Power
    0

    Default Re: DOM model and JavaBeans

    What I want to know is, if the DOM tree should be deleted (if not needed anymore) after the xml file has been parsed.

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,087
    Rep Power
    20

    Default Re: DOM model and JavaBeans

    It should go anyway, assuming you only create it where you use it.
    Java Code:
    public void getStuff() {
       Document doc = createDoc();
       ... code the turns the doc into beans ...
    }
    At the end of that method the Doc will be eligible for GC.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Get JRootPane with JavaBeans
    By James Manley in forum Enterprise JavaBeans (EJB)
    Replies: 3
    Last Post: 03-24-2011, 07:06 AM
  2. Difference between Javabeans and EJB
    By winkodes in forum Enterprise JavaBeans (EJB)
    Replies: 2
    Last Post: 03-18-2009, 02:21 PM
  3. javaBeans with JSP
    By jainpankaj15m in forum Advanced Java
    Replies: 1
    Last Post: 07-25-2007, 01:15 PM
  4. javabeans?
    By sin in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 05-15-2007, 06:42 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •