Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 11th, 2012  |  syntax: None  |  size: 0.27 KB  |  hits: 59  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. JSP String formatting Truncate
  2. <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
  3.  
  4. ${fn:substring(myVariable, 0, 5)}
  5.        
  6. <%
  7.     int i = 5; // This is the number of characters to truncate
  8.  
  9.     String s = "This is a String";
  10.  
  11.     s = s.substring(0, i);
  12. %>