Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getAttributeNames()

 
Ankitt Gupta
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to get the names of the attributes that i have put in the application context.






i am getting

org.apache.catalina.util.Enumerator@6efbef
 
Shruthi Sam
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
you are trying to print the enumerator object. That is why you got that output.

you have to use,

e.nextElement() method to retrieve the values.

Check whether e is having any data using the method e.hasMoreElements() before iterating.
 
Nishan Patel
Ranch Hand
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
# Enumeration e=(Enumeration)getServletContext().getAttributeNames();
# out.println("<html><body>");
# out.println(e);
# out.println("</body></html>");


Returns:

an Enumeration of String objects specifying the names of all the objects bound to this session.

so you have to print value of your Enumeration object use again for loop and print value.
 
Ankitt Gupta
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey thanks shruthi,nishan

i set the attribute by



leaguelist1 is a LinkedList

but now i am getting

com.sun.jsp.tagFileJarUrlsCache com.sun.jsp.tldUriToLocationMap org.apache.catalina.jsp_classpath jspx.1st.request com.sun.jsp.taglibraryCache com.sun.appserv.jsp.resource.injector com.sun.jsp.propertyGroups org.apache.catalina.WELCOME_FILES javax.servlet.context.tempdir org.apache.catalina.resources com.sun.faces.useMyFaces com.sun.servlet.webxml.version
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd imagine that yours is not the only attribute in the context.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic