Example Java Class Converted from a JSP Page

This section provides a tutorial example Java class converted by Tomcat 7 from the JSP page, Hello_Scripting.jsp. Scripting elements included in the JSP page are converted correctly.

What is the location of those Servlet class files converted from my JSP pages by the Tomcat server? The answer is depending on the Tomcat version and configuration settings.

If you are using Tomcat 7 with default settings, JSP pages deployed to the default application folder, .\webapps\ROOT, will be converted to Servlet class files in the default work folder, .\work\Catalina\localhost\_\org\apache\jsp. If you are using other versions of Tomcat, the Servlet class file location could be different.

Here is where I found the converted Servlet class file of my Hello-Scripting.jsp used in the previous tutorial:

JSP page location:

Converted Java source code location:

Compiled Java bytecode location:

Notice that:

Now let's see how the converted Java class looks like. Open Hello_005fScripting_jsp.java:

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

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

public final class Hello_005fScripting_jsp 
    extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

   private String greeting() {
      return "Scripting Elements:";

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

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

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

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

  public void _jspInit() {
    _el_expressionfactory = 
    _jsp_instancemanager = 

  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 {

    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;

      out.write("<!-- Hello_Scripting.jsp\r\n");
"   Copyright (c) 2012, HerongYang.com, All Rights Reserved.\r\n");
      out.print( greeting() );
 out.println("Hello world!"); 
      out.print( "-- From JSP" );
    } catch (java.lang.Throwable t) {
      if (!(t instanceof javax.servlet.jsp.SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try { out.clearBuffer(); } catch (java.io.IOException e) {}
        if (_jspx_page_context != null) 
        else throw new ServletException(t);
    } finally {

I don't see any surprises. Do you?

Last update: 2012.

Table of Contents

 About This Book

 JSP (JavaServer Pages) Overview

 Tomcat 7 Installation on Windows Systems

JSP Scripting Elements

 What Are Scripting Elements?

 Converting JSP Pages with Scripting Elements

 Example JSP Page with Scripting Elements

Example Java Class Converted from a JSP Page

 Mixing Static Data with Scriptlets for Compound Statements

 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)

 JSTL Core Library

 JSP Custom Tags

 JSP Java Tag Interface

 Custom Tag Attributes

 Multiple Tags Working Together

 File Upload Test Application

 Outdated Tutorials


 PDF Printing Version