Outdated: Java Class Converted by Tomcat 4.1.18

This section provides a tutorial example to show how Tomcat 4.1.18 converts a JSP page, hello.jsp, into a Java Servlet class source code, hello_jsp.java.

To see how Tomcat 4 converts a JSP page into a Java class and compiles it to a bytecode, let's open the hello.jsp JSP page again:

<html><body>
<% out.println("Hello world!"); %>
</body></html>

Then save hello.jsp to \local\jakarta-tomcat-4.1.18\webapps\ROOT, and run IE with url: http://localhost:8080/hello.jsp. You should see "Hello world!" in the IE window.

Now, if you look at the directory: \local\jakarta-tomcat-4.1.18\work\standalone\localhost\_, you will see a Java file: hello_jsp.java,

package org.apache.jsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import org.apache.jasper.runtime.*;

public class hello_jsp extends HttpJspBase {

  private static java.util.Vector _jspx_includes;

  public java.util.List getIncludes() {
    return _jspx_includes;
  }

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

    JspFactory _jspxFactory = null;
    javax.servlet.jsp.PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;

    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html;charset=ISO-8859-1");
      pageContext = _jspxFactory.getPageContext(
           this, request, response, null, true, 8192, true);
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("<html>");
      out.write("<body>\r\n");
 out.println("Hello world!"); 
      out.write("\r\n");
      out.write("</body>");
      out.write("</html>");
    } catch (Throwable t) {
      out = _jspx_out;
      if (out != null && out.getBufferSize() != 0)
        out.clearBuffer();
      if (pageContext != null) pageContext.handlePageException(t);
    } finally {
      if (_jspxFactory != null) 
         _jspxFactory.releasePageContext(pageContext);
    }
  }
}

You will also see a Java bytecode file: hello_jsp.class.

What happened here was that Tomcat, the JSP Web server, has converted hello.jsp into hello_jsp.java, and compiled it to hello_jsp.class.

The Java file, hello_jsp.java, shows that:

Last update: 2006.

Table of Contents

 About This Book

 JSP (JavaServer Pages) Overview

 Tomcat 7 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)

 JSTL Core Library

 JSP Custom Tags

 JSP Java Tag Interface

 Custom Tag Attributes

 Multiple Tags Working Together

 File Upload Test Application

Outdated Tutorials

 Outdated: Installing Tomcat 4.1.18

Outdated: Java Class Converted by Tomcat 4.1.18

 Outdated: Hijacking Servlet Converted from JSP

 Outdated: Using Perl LWP::Debug Module to Debug

 Outdated: Installing JSTL 1.0 Apache Implementation

 Outdated: Upgrade JDK 1.3 to JDK 1.4 on Tomcat 4.1

 Outdated: Compilation Errors with JDK 1.4

 Outdated: Using JavaBean without Import Element Error

 Outdated: Installing Tomcat 5.5.7

 References

 PDF Printing Version