I have this nav code in multiple JSP files:
<ul id="nav">
<li ><a href="/home">Home</a></li>
<li class="active" ><a href="/bills">Bills</a></li>
<li ><a href="/invoices">Invoices</a></li>
</ul>
What’s the best way to abstract out this code and make the selection of the active nav element programmatic rather than manually defined in the html?
Use
<jsp:include>to include reuseable JSP code fragments.Use JSTL/EL to dynamically control HTML output.
Use a Javabean class to represent a model which can be used throughout all code layers.
Use a
ServletContextListenerto preload applicationwide data.