What is jstl?and types of Jstl in jsp?

gm friends ! happy Sunday .  Enjoy your Sunday with beautiful Sunday love feast.

So our Today’s topic is What is JSTL? and What are the types of jstl.?

what is Jstl?

The JSP standard tag library (JSTL) represents a set of tags to simplify the jsp development.

benefits of using jstl.

1.minimize the mount of scriptlet code in a jsp.

2.avoid dumping thousands of line of code in a jsp page.

3.jsp page is simple main focus of jsp is only the presentation.

4.tag is reusable.

5.fast development jstl provides many tagsthat simplify the jsp.

6.no need to use the scriptlet tag.

7.It avoids the use of scriptlet tag.

What are the types of jsp standard tag library.?

==There are mainly 5 types of jstl tags.

Oracle created a specification for the standard tag .

1.core tag:

2.message formatting I18 N:

3.functions tag:

4.XML tag:

so now we take very simple definition for all these tags.

a very simple definition for better understanding and easy.

so the first one is

1.core tag.: this tag is used for handling variables and  looping and condition.

2.message formatting I 18 N(internationalization):-this message tag is used for handling interlization and formatting.

3.functions:there function tag is used for string manipulation and getting the sizes of a collection.

4.XML:there’s also a group of tag for Xml for parsing and setting Xml data.

5.SQL : for accessing database.

but in this article we are going to dive into only two tags that is the core tag and the function tag because  this tag is mostly used in developing the web application in jsp.

So lets get start !!—

So i am just writing the name of the few jsp core tag . I am going to write a code for all these tag so if you want to get the code  of all the jsp core tag then you can go and continue with java t point that  sites explain very nicely about all the code of jsp  core tag.

So now here are the examples of jsp core tag.

  1. catch:-  catches any throw able  to occurs in the body.
  2. choose:-conditional tag that can be used for exclusive operations  ,similar to switch statement .
  3. if:—-simple if /then condition.
  4. import:–retrieves a url  and express it contents on the page or avariable.
  5. for Each:—–Iterates over a collection of values.
  6. for tokens:-Iterates over a collection of tokens.
  7. out:——-used in scriptlets to display output, similar to <% =———-%>
  8. otherwise:—used with the choose tag to handle the else clause 
  9. param:–    adds a  parameter to a url.
  10. redirect:——redirect the browser to a new url.
  11. remove:——remove a scope variable
  12. set:–assign an expression value to a variable.
  13. url:-  defines a url with query parameters.

when:-.used with the <.choose > tag when a condition is true.

 so there are the examples of jsp core tag now we we take one example with written code.

so lets see:-



Every page that uses the core tag must use this references :

<%  @ taglib uri=”http://java.sun.com/jsp/jstl/core ”   prefix =”c” %>

In the reference we use the prefix c for the jsp core tag:-



<title>core tag example</title>

<h3>core tag</h3>



//  just create sample data normaly provided by mvc.

String [ ] cities ={“ranchi”, “delhi”,      “dumka”};

pageContext.set Attribute(“my Cities “,cities);

//here my Cities is the name of the attribute and cities is the value of this attribute.


<C:foEeach                  var=  “tempcity”                          items= “${my Cities}”>

//where temp city = temp variable and my cities = name of the attribute

${temp City}






ranchi delhi dumka

so this was the code of jsp custom tag .as i said there are many core tags so you can practise on your own with the following website


Now i will cover the topic of jsp function tag and their examples with code and about prefix so have a look :-

  • Every page that uses the function tags must include this reference :
  • <% @taglib  uri   =    “http://java.sun.com/jsp/jstl/functions” prefix=”fn”>
  • <————————–code example————————————————->
  • <C: set var =”data” value=”goodmorning”  />

length of the  String <b> ${data}</b>:${fn:length (data)}=  11.

//so that the length of the string “goodmorning ”  is 11.

this is the basic code now we will write the ful code of jsp function tag:

show me the code:—————————————————

<% @ taglib uri=”http://java.sun.com/jsp/jstl/core=”  prefix=”c” %>     // c for core tag.

<% @ taglib uri=”http://java.sun.com/jsp/jstl/core=”   prefix=”fn” %>  //fn for function tag



<C:Set var=”data ”   value=”good morning”/>

Length of the String <b> ${data} </b>: $ {   fn:   length (data)   }

Uppercase version of the string <b>${data}  </b> :${fn:    to    uppercase(data)   }





so the output of this code is:

length of the string goodmorning is: 11.

uppercase version of the string goodmorning is:GOODMORNING



Hope you will like my article and get benefited keep practising and keep coding.














Leave a Reply

Your email address will not be published. Required fields are marked *