"Hello world!" with JSTL

This section provides a tutorial example to test the installation of JSTL 1.2 JAR file developed by the Oracle GlassFish project. The example print out a hello message with the 'c:out' tag.

To understand how JSTL works, let's try a very simple example, using JSTL to say hello in the browser window. Here is my JSP source code, hello_jstl.jsp:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:out value="Hello world! - From JSTL"/>

Save it to \local\tomcat\webapps\ROOT, and run IE with URL: http://localhost:8080/hello_jstl.jsp. I got the prefect message "Hello world! - From JSTL" in the IE window!

Now let's see the Servlet class converted by Tomcat server from on my JSP page with the "c:out" tag. The Servlet class is located in the C:\local\tomcat\work\Catalina\localhost\ROOT\org\apache\jsp directory. Open the converted class file, hello_005fjstl_jsp.java:

 * Generated by the Jasper component of Apache Tomcat
 * Version: Apache Tomcat/9.0.12
package org.apache.jsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;

public final class hello_005fjstl_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent,
                 org.apache.jasper.runtime.JspSourceImports {

  private static final javax.servlet.jsp.JspFactory _jspxFactory =

  private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants;

  static {
    _jspx_dependants = new java.util.HashMap<java.lang.String,java.lang.Long>(2);

  private static final java.util.Set<java.lang.String> _jspx_imports_packages;

  private static final java.util.Set<java.lang.String> _jspx_imports_classes;

  static {
    _jspx_imports_packages = new java.util.HashSet<>();
    _jspx_imports_classes = null;

  private org.apache.jasper.runtime.TagHandlerPool 

  private volatile javax.el.ExpressionFactory _el_expressionfactory;
  private volatile org.apache.tomcat.InstanceManager _jsp_instancemanager;

  public java.util.Map<java.lang.String,java.lang.Long> getDependants() {
    return _jspx_dependants;

  public java.util.Set<java.lang.String> getPackageImports() {
    return _jspx_imports_packages;

  public java.util.Set<java.lang.String> getClassImports() {
    return _jspx_imports_classes;

  public javax.el.ExpressionFactory _jsp_getExpressionFactory() {
    if (_el_expressionfactory == null) {
      synchronized (this) {
        if (_el_expressionfactory == null) {
          _el_expressionfactory = 
    return _el_expressionfactory;

  public org.apache.tomcat.InstanceManager _jsp_getInstanceManager() {
    if (_jsp_instancemanager == null) {
      synchronized (this) {
        if (_jsp_instancemanager == null) {
          _jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory
    return _jsp_instancemanager;

  public void _jspInit() {
    = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig());

  public void _jspDestroy() {

  public void _jspService(final javax.servlet.http.HttpServletRequest request, 
      final javax.servlet.http.HttpServletResponse response)
      throws java.io.IOException, javax.servlet.ServletException {

    if (!javax.servlet.DispatcherType.ERROR.equals(request.getDispatcherType())) {
      final java.lang.String _jspx_method = request.getMethod();
      if ("OPTIONS".equals(_jspx_method)) {
        response.setHeader("Allow","GET, HEAD, POST, OPTIONS");
      if (!"GET".equals(_jspx_method) && !"POST".equals(_jspx_method) 
      && !"HEAD".equals(_jspx_method)) {
        response.setHeader("Allow","GET, HEAD, POST, OPTIONS");
        "JSPs only permit GET, POST or HEAD. Jasper also permits OPTIONS");

    final javax.servlet.jsp.PageContext pageContext;
    javax.servlet.http.HttpSession session = null;
    final javax.servlet.ServletContext application;
    final javax.servlet.ServletConfig config;
    javax.servlet.jsp.JspWriter out = null;
    final java.lang.Object page = this;
    javax.servlet.jsp.JspWriter _jspx_out = null;
    javax.servlet.jsp.PageContext _jspx_page_context = null;

    try {
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      if (_jspx_meth_c_005fout_005f0(_jspx_page_context))
    } catch (java.lang.Throwable t) {
      if (!(t instanceof javax.servlet.jsp.SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try {
            if (response.isCommitted()) {
            } else {
          } catch (java.io.IOException e) {}
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
        else throw new ServletException(t);
    } finally {

  private boolean _jspx_meth_c_005fout_005f0(javax.servlet.jsp.PageContext 
          throws java.lang.Throwable {
    javax.servlet.jsp.PageContext pageContext = _jspx_page_context;
    javax.servlet.jsp.JspWriter out = _jspx_page_context.getOut();
    //  c:out
    org.apache.taglibs.standard.tag.rt.core.OutTag _jspx_th_c_005fout_005f0 
    = (org.apache.taglibs.standard.tag.rt.core.OutTag) 
    boolean _jspx_th_c_005fout_005f0_reused = false;
    try {
      // /hello_jstl.jsp(3,0) name = value type = null reqTime = true 
      // required = true fragment = false deferredValue = false expectedTypeName 
      // = null deferredMethod = false methodSignature = null
      _jspx_th_c_005fout_005f0.setValue("Hello world! - From JSTL");
      int _jspx_eval_c_005fout_005f0 = _jspx_th_c_005fout_005f0.doStartTag();
      if (_jspx_th_c_005fout_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
        return true;
      _jspx_th_c_005fout_005f0_reused = true;
    } finally {
      _jsp_getInstanceManager(), _jspx_th_c_005fout_005f0_reused);
    return false;

As you can see, the "c:out" tag is replaced by method call. The method then interacts with the class org.apache.taglibs.standard.tag.el.core.OutTag, where the "out" tag is implemented. The implementation is probably very simple, may be just an out.write() statement.

Last update: 2018.

Table of Contents

 About This Book

 JSP (JavaServer Pages) Overview

 Tomcat Installation on Windows Systems

 JSP Scripting Elements

 Java Servlet Introduction

 JSP Implicit Objects

 Syntax of JSP Pages and JSP Documents

 JSP Application Session

 Managing Cookies in JSP Pages

 JavaBean Objects and "useBean" Action Elements

 Managing HTTP Response Header Lines

 Non-ASCII Characters Support in JSP Pages

 Performance of JSP Pages

 EL (Expression Language)

Overview of JSTL (JSP Standard Tag Libraries)

 What is JSTL

 Installing GlassFish JSTL on Tomcat

"Hello world!" with JSTL

 JSTL in XML Style JSP Pages

 General Syntax of JSTL Tags

 NoClassDefFoundError - LoopTag/ForEachTag

 Installing JSTL 1.2 API JAR File

 JSTL Example - Loop Tag on Map Objects

 JSTL Core Library

 JSP Custom Tags

 JSP Java Tag Interface

 Custom Tag Attributes

 Multiple Tags Working Together

 File Upload Test Application

 Outdated Tutorials


 Full Version in PDF/EPUB