Title: RE: Please help! Recursive loop in JSP

I haven't tested the code and wrote it in less than 10 minutes so you might want to try it out first but solution should be along one of those lines... Code below is probably a combination of JSP, asp, vb and java so use jsp equivalent of course. :)

pseudocode:

myId = 4 (jackie)
myParent = 9 (garbage for the first pass)

print parent's name (jackie in this case)
call recurseMe(myId, myParent)
...

***********************************************************************
function recurseMe(myId, myParent)
  While myParent != 0
    conn.execute "select name from table where parent = " + myId (this is your recordset of john, cathy and jeff on the first pass around)

 
    while not recordset.eof
      print out name (this is the child's name)
      myParent = recordset.parent
      recurse(recordset.id, recordset.parent)           
      recordset.moveNext()
    end of while
  end of while
end of recurseMe
***********************************************************************
 


-----Original Message-----
From: Frank Mancini [mailto:[EMAIL PROTECTED]]
Sent: Monday, November 12, 2001 5:04 PM
To: [EMAIL PROTECTED]
Subject: Please help! Recursive loop in JSP


I have a recursive looping problem here.

For example, say I have this table

id, name, parent

1,john,4
2,bill,3
3,cathy,4
4,jackie,0
5,jeff,4
6,joe,7
7,amy,0

Essentially,

jackie doesn't have a parent, but has john, jeff and cathy as children. bill
is the child of cathy and thus jackies grandchild.


How would I do this query such that I say I want to see all the children
(including everyone below him/her) below, say jackie...this is really a self
join to oneself with an unknown number of levels below.

How would I do this in jsp do display all of jackies relatives below her?

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to