Apekshit
  • Home
  • Tutorials
  • Interview Questions
  • About
  • Contact
  • Core JAVA
  • JSP
  • JSTL
  • JDBC
  • Algorithms
  • HTML
  • SQL
  • JavaScript
  • JSP Tutorial
    • JSP Introduction
    • JSP in Eclipse
    • JSP Scripting Elements
    • JSP Directives
    • JSP Page Directive
    • JSP Taglib Directive
    • JSP Include Directive
    • JSP Forward Tag
    • JSP Redirect
    • JSP Forward Vs Redirect
    • JSP Include Tag
    • JSP UseBean Tag
    • JSP SetProperty
    • JSP GetProperty
    • JSP Implicit Objects
    • JSP Request Object
    • JSP Response Object
    • JSP pageContext Object
    • JSP session Object
    • JSP out Object
    • JSP application Object
    • JSP config Object
    • JSP Scopes
    • JSP Page Scope
    • JSP Request Scope
    • JSP Session Scope
    • JSP Application Scope
    • JSP Output Comment
    • JSP Hidden Comment
  • JSTL Tutorial
    • JSTL Introduction
    • JSTL Core Tags
    • JSTL out tag
    • JSTL ForEach Tag
    • JSTL Set Tag
    • JSTL If Tag
    • JSTL Catch Tag
    • JSTL If Else Statement
    • JSTL Choose Tag
    • JSTL Remove Tag
    • JSTL Import Tag
    • JSTL ForTokens Tag
    • JSTL Param Tag
    • JSTL url Tag
    • JSTL Redirect Tag
    • JSTL Functions Tags
    • JSTL Length Function
    • JSTL substringBefore
    • JSTL Substring Function
    • JSTL Trim Function
    • JSTL Replace Function
    • JSTL Contains Function
    • JSTL Join Function
    • JSTL IndexOf Function
    • JSTL split Function
    • JSTL StartsWith
    • JSTL endsWith Function
    • JSTL toLowerCase Function
    • JSTL formatNumber Tag
    • JSTL minFractionDigits
    • JSTL toUpperCase Function
    • JSTL containsIgnoreCase
    • JSTL Formatting Tags
    • JSTL maxFractionDigits
    • JSTL minIntegerDigits
    • JSTL maxIntegerDigits
    • JSTL Format Currency
    • JSTL SQL dateParam Tag
    • JSTL SQL Transaction Tag
    • JSTL SQL Tags
    • JSTL SQL Transaction Isolation Attribute
    • JSTL groupingUsed
    • JSTL SQL SetDataSource
    • JSTL Format Percent
    • JSTL SQL Query Tag
    • JSTL SQL UPDATE Tag
    • JSTL SQL Param Tag
    • JSTL Message Format
    • JSTL Set Locale
    • JSTL Parse Number
    • JSTL escapeXml Function
    • JSTL substringAfter
  • JSP Exception Handling
    • JspTagException
    • JasperException:
    • PropertyNotFoundException
    • javax.servlet.jsp.JspTagException: Don't know how to iterate

JSTL substringBefore Function

JSTL SubstringBefore function is used to get the substring of target string. This function takes 2 parameters.

First parameter in JSTL SubstringBefore function is the target String from which you want to derive the substring.

Second parameter in JSTL SubstringBefore function is the substring which breaks the string in to 2 parts and function returns the substring before it.

JSTL substringBefore Function Example:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>JSTL substringBefore Function Example</title>
</head>
<body>
	<c:out value="${fn:substring('Hello-Jwalant','-')}"></c:out>
</body>
</html>


Output:  Hello

As you can see above, JSTL substringBefore function takes 'Hello-Jwalant' string as target String parameter, '-' is the substring which decides the result. substringBefore function returns the substring before '-'.

JSTL Substring Function ⇐ PREVIOUS
NEXT ⇒ JSTL substringAfter Function
Java is a trademark of Oracle.
Apekshit.com is just for learning and testing. To improve basic understanding we provide some examples. We are constantly reviewing it to avoid errors, but we cannot warrant full correctness of all content.