Stack Trace Visibility via JNDI lookup

by Bruce on June 7, 2010

We use a JNDI lookup to control whether a stack trace is visible. This allows us to have the stack trace visible in our development and test environments, but not in production. We have have maven deploy the correct according to your environment (which is outside the scope of this post). For example, in a test environment the would be deployed whereas the would be deployed for production. There are other ways to accomplish turning stack traces on and off automatically according to your environment. Why not show the stack trace everywhere? Security, hide as much from a potential hacker (besides QA and the security team) as is possible.


<jee:jndi-lookup jndi-name="ShowStackTrace" id="showStackTrace" />

add this to the Container Resource element

<Environment name="ShowStackTrace" 
            value="${screening.showStackTrace}" />


and finally, have something like this in the jsp configured to display the exception…

<c:if test="${showStackTrace}">
    <div id="dev">
        <a href="#" id="exception-toggle">Show stack trace</a>
        <div id="exception" style="display:none;">
            <c:if test="${not empty exception}">
                    <c:forEach items="${exception.stackTrace}" 

Leave a Comment

Previous post:

Next post: