Saturday 9 February 2013

Enabling JSTL (JSP Standard Tag Library) in your web application

JSTL is a good to enable tag library while developing Java Server Pages. It speeds up the development and lets you write logical blocks in fewer lines.

The JSTL library to be included to your web application depends on the version of Servlet you are using. The steps mentioned here lets you choose the right JSTL library version and include it to your web application. We continue from the previous post where we built the web application.

Locating Servlet version

  1. Open web.xml file located in WEB-INF folder.
  2. Check the version attribute of web-app tag.
    Here, the version is 2.5.

Downloading JSTL package depending upon the version

Refer this link to know which version you would need to download depending upon your Servlet version. You will find the download link for each version. I downloaded javax.servlet.jsp.jstl-1.2.1.jar as I have 2.5 version.

Using JSTL in your application

  1. Create a lib folder under WEB-INF.

  2. Copy the downloaded jar file into the lib folder.
  3. Include library to your JSPs and start using it. Here I have modified the existing function to use JSTL tag.
    <%@ page language="java" contentType="text/html; charset=UTF-8"
    <%@ taglib uri="" prefix="c"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Hello World</title>
      Object message = request.getAttribute("message");
      if (message == null) {
     <form action="sayHello" method="post">
      <input type="submit" value="Submit" />
      } else {
     <c:if test="${empty message}">
      <form action="sayHello" method="post">
       <input type="submit" value="Submit" />
     <c:if test="${not empty message}">
      <c:out value="${message}" />


  1. Great post. This is very useful. Thanks for sharing.

    ppc training in chennai

  2. Excellent post! Thanks for sharing such a useful post.

    web design training in chennai

  3. Normal website design only suitable for desktop screen and it does not appear on new devices like Smart phone and tablets etc.

  4. It speeds up the development and lets you write logical blocks in fewer lines.web design tips

  5. Indeed, even the words like charming and intriguing can't do full equity with regards to depicting this blog.
    e-commerce website

  6. The writer, through this blog, has earned respect from many for all the right reasons.
    software development company in delhi

  7. I've proper selected to build a blog, which I hold been deficient to do for a during. Acknowledges for this inform, it's really serviceable!
    mason soiza