JSP JSTL Using varStatus to Add CSS Class On Last Element

Often when iterating a collection to display it on table specific css class need to be added to the last row for styling purpose, eg:

<tr><td>Jim</td><td>34</td></tr>
<tr><td>Bob</td><td>30</td></tr>
<tr class="last"><td>Susan</td><td>28</td></tr>

This can be achieved on JSP JSTL core tag by using varStatus attribute:

<c:forEach var="user" items="${users}" varStatus="status">
  <tr ${status.last ? 'class="last"' : ''}>
    <td>${user.name}</td>
    <td>${user.age}</td>
  </tr>
</c:forEach>

On varStatus you define what is the variable name which will hold the loop iteration status. This variable then contain information whether or not we’re on the last iteration, and place specific content accordingly. See the javadoc reference for LoopTagStatus for more info.

The question mark and colon syntax ${status.last ? 'class="last"' : ''} is similar to standard Java syntax. It will print the content class="last" only is status.last is true (ie: we’re on the last iteration of loop)

Advertisements

LogMeIn Hamachi Offline After Logging Out From RDP

I’ve noticed this behavior for a while, and did some searching over the internet. I found this post from hamachi forum about how to prevent hamachi going offline when RDP session is logged out’

So as a workaround you can log off your RDP without closing the session creating a shourtcut in your desktop directed to “%windir%\System32\tscon.exe RDP-Tcp#0 /dest:console” and run as administrator. This will log you off and leave the session open. Just saying.

So far this solution seem to work for me, need to figure out what will happen when another user logs in into the PC.

Windows 7 Unable to Import Trusted Root Certification Authorities

Windows has its own trusted root CA certificates (which is also used by Google Chrome browsers). If your company is running your own internal CA, an additional CA certificate has to be added to it.

I encountered a very strange problem where everytime I import it via certmgr.msc the dialog says The import was successful but the certificate was never imported.

Solution 1: Use Administrator Elevated Privilege

  1. Click on windows icon -> Search for cmd
  2. Right click cmd.exe -> Run as Administrator
  3. From the command prompt, run certmgr.msc
  4. Continue with the import process

Solution 2: Edit Group Policy on Domain Controller

It is common for PCs in office environment to be connected to a network domain. The default domain policy is to disallow users from adding their own trusted root CA certificate.

To get around this problem, use group policy management editor on your domain controller and find **Certificate Path Validation Settings**. Update the settings into following:

cert_import2

See this Microsoft article for more info.