Open In App

JSTL fn:toUpperCase() Function

Last Updated : 14 Dec, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

In JSTL, the fn:toUpperCase() function is used to transform all the characters in a specified string to uppercase. If the input string is in lowercase, then this function can convert all the characters into uppercase.

In this article, we will see the Syntax along with Parameters and detailed implementation of JSTL fn:toUpperCase() Function in terms of example.

Syntax of fn:toUpperCase() Function

${fn:toUpperCase(string)}

Where,

  • ${fn:toUpperCase()}: This is the expression used to convert the input string into the characters of Uppercase.
  • string: This is the input string to be converted into the uppercase characters.

Example of fn:toUpperCase() Function

In this example, we will discuss the use of fn:toUpperCase() in a JSP page.

HTML




<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ 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>JSTL fn:toUpperCase() Example</title>
  </head>
  <body>
    <c:set var="inputString" value="GeeksforGeeks"/>
    <h3>Original String: ${inputString}</h3>
      
    <p>Uppercase String: ${fn:toUpperCase(inputString)}</p>
      
  </body>
</html>


Output:

Original String: GeeksforGeeks
Uppercase String: GEEKSFORGEEKS

Output Screen of fn:toUpperCase() Function:

Output for toUpperCase method

Explanation of the above Program:

  • inputString initialized with the value “GeeksforGeeks” using c:set
  • Then, we print or display this inputString in <h3> tag of HTML.
  • the function of fn:toUpperCase() we are transforming the inputString characters into uppercase, which becomes “GEEKSFORGEEKS“.
  • Lastly, we are displaying this converted output using the <p> tag of HTML.

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads