Reputation: 111
I am working on a web application where I get some string data using Java Servlets and then subsequently display that data on a JSP view using JSTL. Below is the code snippet:
<table border="1" width=100%>
<th style="width: 10%">S. NUMBER</th>
<th style="width:35%"> First Name </th>
<th style="width: 35%"> Second Name </th>
<th style="width: 10%">Student ID</th>
<th style="width: 10%">Student Class</th>
<c:forEach items="${sortedResults}" var="result">
<tr>
<td>${result.counter}</td>
<td>${result.sequenceIntEx}</td>
<td>${result.lName}</td>
<td>${result.sID}</td>
<td>${result.sClass}</td>
</tr>
</c:forEach>
For example, the lName field, i want to display the 3rd and 4th characters in a bigger font size with different color. Any thoughts?
Upvotes: 0
Views: 1664
Reputation: 111
So, i got this working using substring functions in JSTL. First, the following needs to be imported:
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
Then, i used the substrings to do the needed formatting.
<td>${fn:substring(result.sequenceIntEx, 0, 3)}<font size="5" color="red">${fn:substring(result.sequenceIntEx, 3, 5)}</font>${fn:substring(result.sequenceIntEx, 5, 13)}</td>
Thanks
Upvotes: 1
Reputation: 1962
Perhaps assign systematic element names ex. id="td1" id="td2" etc. and then use jsp to generate a css file that matches the automatic element names and filling in any parameters needed depending on your criteria.
Upvotes: 1