Basic JSP Tutorials
Advanced JSP Tutorials
JSP Useful References
JSP Useful Resources
Selected Reading
© 2011 TutorialsPoint.COM
|
JSTL fn:trim() Function
The fn:trim() function removes white space from both ends of a string.
Syntax:
The fn:trim() function has following syntax:
java.lang.String trim(java.lang.String)
|
Example:
Following is the example to explain the functionality of this function:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions"
prefix="fn" %>
<html>
<head>
<title>Using JSTL Functions</title>
</head>
<body>
<c:set var="string1" value="This is first String "/>
<p>String (1) Length : ${fn:length(string1)}</p>
<c:set var="string2" value="${fn:trim(string1)}" />
<p>String (2) Length : ${fn:length(string2)}</p>
<p>Final string : ${string2}</p>
</body>
</html>
|
This would produce following result:
String (1) Length : 29
String (2) Length : 20
Final string : This is first String
|
|
|
|