Display element in JSP only if model element not null


Dev-Bookmarks Logo

Save up to a workweek a year by efficiently managing your dev bookmarks, on www.bookmarks.dev. Share your favorites with the community and they will be published on Github - Star


How to display element in JSP only if model element not null

To do that you can use the or _ tags to make conditional rendering in Java Server Pages (JSP) using the JSP Standard Tag Library (JSTL) like in the following code snippet:

<div>
	<c:if test="${not empty podcast.twitterPage}">
		<a href="${podcast.twitterPage}" target="_blank" class="icon-twitter-producer producer-social"></a>
	</c:if> 			 		
	<c:if test="${not empty podcast.fbPage}">
		<a href="${podcast.fbPage}" target="_blank" class="icon-facebook-producer producer-social"></a>
	</c:if> 			 		
	<c:if test="${not empty podcast.gplusPage}">
		<a href="${podcast.gplusPage}" target="_blank" class="icon-google-plus-producer producer-social"></a>
	</c:if> 
</div>

Podcastpedia.org on GitHub

A cleaner multi-stage continuous deployment on Kubernetes of a Create React App with kustomize, helm and skaffold

This blog posts presents a clean way to make a multi-stage deployment of a Create React App on a Kubernetes Cluster. Deployments with kubectl, helm charts, kustomize and skaffold are presented. Continue reading