Re: Please help! Recursive loop in JSP

2001-11-13 Thread Scott Watson

I don't think so I have been using it since version 7.

Give it a try on your instance.

Happy hunting.
Scott.




"Chen, Gin"
  cc:
Sent by: A   Subject: Re: Please help! Recursive 
loop in JSP
mailing list
about Java Server
Pages
specification and
reference


.


11/13/01 03:01 PM
Please respond to
A mailing list
about Java Server
Pages
specification and
reference






Thats pretty cool Scott. But its only available using Oracle 9i. :P
Heres a link to it for those too lazy to look it up :)


http://download-west.oracle.com/otndoc/oracle9i/901_doc/server.901/a90125/qu

eries2.htm

-Tim

-Original Message-
From: Scott Watson [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 13, 2001 2:51 PM
To: [EMAIL PROTECTED]
Subject: Re: Please help! Recursive loop in JSP


Joe,

You can get more information at otn.oracle.com or do a search on google.
I believe these type of queries are called Hierarchical Queries.

Your DBA should be able to provide you with more information.

The level pseudo column is what tells you how far from the root this record
can be found.

Scott.




Joe Cheng
<[EMAIL PROTECTED]>To:
[EMAIL PROTECTED]
Sent by: A   cc:
mailing list Subject: Re: Please help!
Recursive loop in JSP
about Java Server
Pages
specification and
reference


.


11/13/01 11:00 AM
Please respond to
A mailing list
about Java Server
Pages
specification and
reference






>> If you are selecting data from a database and that database happens to
be
Oracle look at the connect by clause.  It does everything you are looking
for. <<

that's really interesting, I've never heard of "connect by".  can you or
Ross provide more detail, i.e. what does the resulting recordset look like?

===
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

===
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

===
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

===
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



Re: Please help! Recursive loop in JSP

2001-11-13 Thread Chen, Gin

I was wrong. Its also in Oracle 8i. :P
http://technet.oracle.com/docs/products/oracle8i/doc_library/817_doc/server.
817/a85397.pdf
-Tim

-Original Message-
From: Chen, Gin [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 13, 2001 3:02 PM
To: [EMAIL PROTECTED]
Subject: Re: Please help! Recursive loop in JSP


Thats pretty cool Scott. But its only available using Oracle 9i. :P
Heres a link to it for those too lazy to look it up :)


http://download-west.oracle.com/otndoc/oracle9i/901_doc/server.901/a90125/qu
eries2.htm

-Tim

-Original Message-
From: Scott Watson [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 13, 2001 2:51 PM
To: [EMAIL PROTECTED]
Subject: Re: Please help! Recursive loop in JSP


Joe,

You can get more information at otn.oracle.com or do a search on google.
I believe these type of queries are called Hierarchical Queries.

Your DBA should be able to provide you with more information.

The level pseudo column is what tells you how far from the root this record
can be found.

Scott.




Joe Cheng
<[EMAIL PROTECTED]>To:
[EMAIL PROTECTED]
Sent by: A   cc:
mailing list Subject:     Re: Please help!
Recursive loop in JSP
about Java Server
Pages
specification and
reference


.


11/13/01 11:00 AM
Please respond to
A mailing list
about Java Server
Pages
specification and
reference






>> If you are selecting data from a database and that database happens to
be
Oracle look at the connect by clause.  It does everything you are looking
for. <<

that's really interesting, I've never heard of "connect by".  can you or
Ross provide more detail, i.e. what does the resulting recordset look like?

===
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

===
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

===
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

===
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



Re: Please help! Recursive loop in JSP

2001-11-13 Thread Chen, Gin

Thats pretty cool Scott. But its only available using Oracle 9i. :P
Heres a link to it for those too lazy to look it up :)


http://download-west.oracle.com/otndoc/oracle9i/901_doc/server.901/a90125/qu
eries2.htm

-Tim

-Original Message-
From: Scott Watson [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 13, 2001 2:51 PM
To: [EMAIL PROTECTED]
Subject: Re: Please help! Recursive loop in JSP


Joe,

You can get more information at otn.oracle.com or do a search on google.
I believe these type of queries are called Hierarchical Queries.

Your DBA should be able to provide you with more information.

The level pseudo column is what tells you how far from the root this record
can be found.

Scott.




Joe Cheng
<[EMAIL PROTECTED]>To:
[EMAIL PROTECTED]
Sent by: A   cc:
mailing list Subject:     Re: Please help!
Recursive loop in JSP
about Java Server
Pages
specification and
reference


.


11/13/01 11:00 AM
Please respond to
A mailing list
about Java Server
Pages
specification and
reference






>> If you are selecting data from a database and that database happens to
be
Oracle look at the connect by clause.  It does everything you are looking
for. <<

that's really interesting, I've never heard of "connect by".  can you or
Ross provide more detail, i.e. what does the resulting recordset look like?

===
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

===
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

===
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



Re: Please help! Recursive loop in JSP

2001-11-13 Thread Scott Watson

Joe,

You can get more information at otn.oracle.com or do a search on google.
I believe these type of queries are called Hierarchical Queries.

Your DBA should be able to provide you with more information.

The level pseudo column is what tells you how far from the root this record
can be found.

Scott.




Joe Cheng
<[EMAIL PROTECTED]>To: [EMAIL PROTECTED]
Sent by: A   cc:
mailing list Subject:     Re: Please help! Recursive 
loop in JSP
about Java Server
Pages
specification and
reference


.


11/13/01 11:00 AM
Please respond to
A mailing list
about Java Server
Pages
specification and
reference






>> If you are selecting data from a database and that database happens to
be
Oracle look at the connect by clause.  It does everything you are looking
for. <<

that's really interesting, I've never heard of "connect by".  can you or
Ross provide more detail, i.e. what does the resulting recordset look like?

===
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

===
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



Re: Please help! Recursive loop in JSP

2001-11-13 Thread Chen, Gin

What do you mean by multiple vectors?
I have a program that uses a hashtable that stores a vector as objects.
Think of this as categories and items.
If I have a grocery store. I might have categories of
"Canned Foods", "Vegetables", "Meats".
And items inside of them
I have vectors for all the items under one category
so my vector for Canned Foods will look something like:

Beans | Peaches | Corn

I have a hashtable to store these keyed by category name:

Hashtable:
Key Value
"Canned Food"   Vector( Beans | Peaches | Corn )
"Vegetables"Vector( Spinach | Broccoli | Tomato )
"Meats" Vector( Chicken | Veal | Pork )

So my program would do something like: (Not complete and not tested)

private Hashtable myStore;

public void createStore()
{
//database code: not best way to do db code and not
complete!
rCategories = stmt.execute("select category_name from
categories");
while( rCategories.next() )
{
String category = rCategories.getString(1);
Vector vItems = new Vector();
//database code: not best way to do db code and not
complete!
rItems = stmt.execute(
"select item_name from items where
category_name='"+ category +"'");
while( rItems.next() )
{
vItems.add( rs.getString(1) );
}

myStore.put( category, vItems );
}
}
-Tim


-Original Message-
From: Kenny Dao [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 13, 2001 11:10 AM
To: [EMAIL PROTECTED]
Subject: Re: Please help! Recursive loop in JSP


Hi

does any know or have an example of how to store
multiple vectors inside a hashtable?

thank

Ken

>  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


__
Do You Yahoo!?
Find the one for you at Yahoo! Personals
http://personals.yahoo.com

===
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

===
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



Re: Please help! Recursive loop in JSP

2001-11-13 Thread Kenny Dao

Hi

does any know or have an example of how to store
multiple vectors inside a hashtable?

thank

Ken

>  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


__
Do You Yahoo!?
Find the one for you at Yahoo! Personals
http://personals.yahoo.com

===
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



Re: Please help! Recursive loop in JSP

2001-11-13 Thread Joe Cheng

>> If you are selecting data from a database and that database happens to be
Oracle look at the connect by clause.  It does everything you are looking
for. <<

that's really interesting, I've never heard of "connect by".  can you or
Ross provide more detail, i.e. what does the resulting recordset look like?

===
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



Re: Please help! Recursive loop in JSP

2001-11-13 Thread Scott Watson

If you are selecting data from a database and that database happens to be
Oracle look at the connect by clause.  It does everything you are looking
for.

eg
select name, id, level
from yourtable
where
start with id=0/* or put whatever id you want to start looking from */
connect by prior id = parent_id ;

Scott.





Frank Mancini
cc:
Sent by: A   Subject: Re: Please help! Recursive 
loop in JSP
mailing list
about Java Server
Pages
specification and
reference


.


11/12/01 06:16 PM
Please respond to
A mailing list
about Java Server
Pages
specification and
reference






Thanks Joe, ya I want more info. I think we will choose the narrower and
deeper family. Let me know if you have anymore ideas.


>From: Joe Cheng <[EMAIL PROTECTED]>
>Reply-To: A mailing list about Java Server Pages specification and
>reference <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Re: Please help! Recursive loop in JSP
>Date: Mon, 12 Nov 2001 17:21:24 -0500
>
>I had to do this once... fun problem.
>
>First of all, forget about doing it "in JSP"... you should use Java
classes
>for this.
>
>Two ways to do it, IMO.  If you have a large and flat dataset, i.e. many
>records in the table but no trees that go more than a few generations
deep,
>you can have a method in the Person object of signature:
> public Person[] getAllChildren()
>that queries for all the children, and calls getAllChildren() on them, and
>adds the results into some kind of vector.  However, that will result in
>many calls to the database because each getAllChildren() call will cost
you
>a query.
>
>If the dataset is narrower and deeper, i.e. a few very deep families, you
>can create a method that loads up all the data in one query and then
>constructs the objects using a method similar to the above.  The advantage
>of this is that you only have to run the query once; the disadvantages are
>that you have loaded all this data that may or may not be used.
>
>Let me know if you need more detail...
>
>-jmc
>
>-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
>
>
===
>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


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

===
To unsubscribe: mailto [EMAIL PROTECTED] with body: 

Re: Please help! Recursive loop in JSP

2001-11-12 Thread Ross Bonner

1. The easy way if you are using an oracle database, this gets them all in
one query

select name
from table
start with id = ?
connect by parent = prior id

2. use a stack
Brief example...

class Person {
int id;
String name;

   Person(int id, String name) {
  this.id = id;
  this.name = name;
   }
}

// Create node to start with
Person root = new Person(4, "Jackie");
Stack stack = new Stack();

// Place starting node on stack
stack.push(root);
Connection con = ... get connection here
PreparedStatement ps = con.prepareStatement("select id, name from table
where parent = ?");
do {
   Person current = (Person) stack.pop();
   // Print current item on stack
   out.println("" + current.name + "");
   // Set parent to look for
   ps.setInt(1, person.id);

   // Get children
   ResultSet rs = ps.executeQuery();
   while (rs.next()) {
 // Place children on stack
 stack.push(new Person(rs.getInt(1), rs.getString(2)));
   }
   rs.close();
} while(!stack.isEmpty()); // Continue as long as there are more children

ps.close();
con.close();

===
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



Re: Please help! Recursive loop in JSP

2001-11-12 Thread Ross Bonner

1. The easy way if you are using an oracle database, this gets them all in one 
query 

select name 
from table 
start with id = ? 
connect by parent = prior id 

2. use a stack 
Brief example... 

class Person { 
int id; 
String name; 

   Person(int id, String name) { 
  this.id = id; 
  this.name = name; 
   } 
} 

// Create node to start with 
Person root = new Person(4, "Jackie"); 
Stack stack = new Stack(); 

// Place starting node on stack 
stack.push(root); 
Connection con = ... get connection here 
PreparedStatement ps = con.prepareStatement("select id, name from table = 
where parent = ?"); 
do { 
   Person current = (Person) stack.pop(); 
   // Print current item on stack 
   out.println("" + current.name + ""); 
   // Set parent to look for 
   ps.setInt(1, person.id); 

   // Get children 
   ResultSet rs = ps.executeQuery(); 
   while (rs.next()) { 
 // Place children on stack 
 stack.push(new Person(rs.getInt(1), rs.getString(2))); 
   } 
   rs.close(); 
} while(!stack.isEmpty()); // Continue as long as there are more children 

ps.close(); 
con.close(); 




-Original Message-
From:Frank Mancini [EMAIL PROTECTED]
Sent:Mon, 12 Nov 2001 14:04:14 -0800
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




___
Visit http://www.visto.com.
Find out  how companies are linking mobile users to the 
enterprise with Visto.

==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



Re: Please help! Recursive loop in JSP

2001-11-12 Thread Frank Mancini

Thanks Joe, ya I want more info. I think we will choose the narrower and
deeper family. Let me know if you have anymore ideas.


>From: Joe Cheng <[EMAIL PROTECTED]>
>Reply-To: A mailing list about Java Server Pages specification and
>reference <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Re: Please help! Recursive loop in JSP
>Date: Mon, 12 Nov 2001 17:21:24 -0500
>
>I had to do this once... fun problem.
>
>First of all, forget about doing it "in JSP"... you should use Java classes
>for this.
>
>Two ways to do it, IMO.  If you have a large and flat dataset, i.e. many
>records in the table but no trees that go more than a few generations deep,
>you can have a method in the Person object of signature:
> public Person[] getAllChildren()
>that queries for all the children, and calls getAllChildren() on them, and
>adds the results into some kind of vector.  However, that will result in
>many calls to the database because each getAllChildren() call will cost you
>a query.
>
>If the dataset is narrower and deeper, i.e. a few very deep families, you
>can create a method that loads up all the data in one query and then
>constructs the objects using a method similar to the above.  The advantage
>of this is that you only have to run the query once; the disadvantages are
>that you have loaded all this data that may or may not be used.
>
>Let me know if you need more detail...
>
>-jmc
>
>-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
>
>===
>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


_
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



Re: Please help! Recursive loop in JSP

2001-11-12 Thread Jean-Francois Pinero
Title: RE: Please help! Recursive loop in JSP



I
meant to say use java equivalent, not jsp equivalent because a bean should be
used like Chris just mentioned...

  -Original Message-From: Jean-Francois Pinero
  [mailto:[EMAIL PROTECTED]]Sent: Monday, November
  12, 2001 5:29 PMTo: [EMAIL PROTECTED]Subject:
  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



Re: Please help! Recursive loop in JSP

2001-11-12 Thread Chris Tucker

Easiest way to do this is just to set up a recursive method call to go
through each level in the tree.  Effectively you're just doing a tree
traversal, and can apply all the standard algorithms to this: your nodes are
each of the people, and can be picked out using an appropriate SQL query
(e.g. SELECT name FROM People WHERE parent = 4).  You can build this query
for each recursive call, modifying the WHERE clause appropriately.

The problem with this approach is that you can end up with a shedload of
database connections going on, and if the tree is deep or broad you'll
suffer from a hell of a slowdown related to having to initiate a query for
every single person.  You can optimise this by using more complicated WHERE
clauses on your SQL to select everyone at a given level meeting the
appropriate criteria, thereby limiting the number of recursive calls to h
(where h is the height of the tree).  You may also want to maintain a list
of all the nodes you have already processed to check for the a mistake in
the data that leads to a cyclic dependency (e.g. mary is johns mother, mary
is johns daughter).  Your data shouldn't have these in it, but it's a good
idea to check to make sure or you risk crashing the server in a big ol'
recursive loop.  There are further ways to optimise the queries (such as
unrolling your recursion into a loop), but unless this is going to be a real
heavy load situation you're likely to be better off going for code
readibility and maintainability.

As far as doing this in JSP is concerned, you should put the code to do the
actual recursive search into a bean and simply format its output with
appropriate JSP.

Hope that helps,

Chris Tucker

-Original Message-
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Frank Mancini
Sent: Monday, November 12, 2001 2: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

===
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



Re: Please help! Recursive loop in JSP

2001-11-12 Thread Jean-Francois Pinero
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





Re: Please help! Recursive loop in JSP

2001-11-12 Thread Joe Cheng

I had to do this once... fun problem.

First of all, forget about doing it "in JSP"... you should use Java classes
for this.

Two ways to do it, IMO.  If you have a large and flat dataset, i.e. many
records in the table but no trees that go more than a few generations deep,
you can have a method in the Person object of signature:
public Person[] getAllChildren()
that queries for all the children, and calls getAllChildren() on them, and
adds the results into some kind of vector.  However, that will result in
many calls to the database because each getAllChildren() call will cost you
a query.

If the dataset is narrower and deeper, i.e. a few very deep families, you
can create a method that loads up all the data in one query and then
constructs the objects using a method similar to the above.  The advantage
of this is that you only have to run the query once; the disadvantages are
that you have loaded all this data that may or may not be used.

Let me know if you need more detail...

-jmc

-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

===
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



Please help! Recursive loop in JSP

2001-11-12 Thread Frank Mancini

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