JSTL : Display All Request Scope Parameters And Model Attributes Inside JSP Page

Java featured image

One of the most best practices and professional required actions to do before thinking about adding/sending a new model attribute to the jsp page, is to check if you have already an attribute in your jsp that can be used to handle your requirement.

Unfortunately many developers are not aware of this problem and they end up by having duplicated information sending to jsp which apply lot of unoptimized calculation.

But is quite difficult to identify either the needed information is already sent to jsp or not, specially when you’re working on big project.

So the Following trick gives you the ability to display all request scope parameters and model attributes inside JSP page by adding this simple code : 

<ul>
    <c:forEach items="${requestScope}" var="p">
            <li>${p.key} -> ${p.value}</li>
    </c:forEach>
</ul>

After refreshing the page you will see all parameters displayed with their values.


5 2 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x