The beans are just stored in the appropriate scoping object (i.e.
pageContext, request, session, or application). You can get at them using
<scoping object>.getAttribute("beanname"). Or you can get a list of the
names of all the objects stored as attributes on one of those objects using
<scoping object>.getAttributeNames(). As far as I know there's no way of
telling if an object is a Bean or not (as included with <jsp:useBean ... />.
There may be a way, but it may involve going a bit too deep into the
container's bean management system.
Suitable code to just dump all attribute names on all scoping objects might
be:
<%
Enumeration enum = pageContext.getAttributeNames();
while( enum.hasMoreElements() ) {
out.println( enum.nextElement() + "<br>" );
}
enum = request.getAttributeNames();
while( enum.hasMoreElements() ) {
out.println( enum.nextElement() + "<br>" );
}
enum = session.getAttributeNames();
while( enum.hasMoreElements() ) {
out.println( enum.nextElement() + "<br>" );
}
enum = application.getAttributeNames();
while( enum.hasMoreElements() ) {
out.println( enum.nextElement() + "<br>" );
}
%>
That's utterly untested, so don't yell at me if it doesn't work right. And
if the Bean is set to session or application scope, it'll show up even if
it's not available in the page. But you will at least get to see all of the
things tied to your scoping objects, which may be educational.
--chris
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Antony Stace
Sent: Tuesday, December 11, 2001 5:18 PM
To: [EMAIL PROTECTED]
Subject: Printing out all beans available to a jsp page
Hi
How can I print out a list of all the beans available to a jsp page. Ie
I want to include in my jsp page a small section of code which prints
out all the beans that this page can access.
Cheers
Tony
===========================================================================
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