Skip to content

Instantly share code, notes, and snippets.

@nateperry
Last active August 31, 2015 19:22
Show Gist options
  • Save nateperry/c5ecebe34e3cf8cb53ed to your computer and use it in GitHub Desktop.
Save nateperry/c5ecebe34e3cf8cb53ed to your computer and use it in GitHub Desktop.
Simple JSP Object Detailer
<%--
Prints out all properties of a particular object
Slightly Revised version from original: http://stackoverflow.com/a/24576688
--%>
<c:set var="object" value="${SOMEOBJECT}" />
<c:if test="${!empty object.class.declaredFields}">
<h2>Object Attributes <em>&dollar;{object.name}</em></h2>
<ul>
<c:forEach var="attr" items="${object.class.declaredFields}">
<c:catch><li><b>${attr.name}</b>: ${object[attr.name]}</li></c:catch>
</c:forEach>
</ul>
</c:if>
<%-- Displays Java Methods --%>
<c:if test="${!empty object.class.declaredMethods}">
<h2>Object Methods<em>&lt;% object.getName() %&gt;</em></h2>
<ul>
<c:forEach var="attr" items="${object.class.declaredMethods}">
<c:catch><li>${attr.name}</li></c:catch>
</c:forEach>
</ul>
</c:if>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment