JSP Tutorials - Herong's Tutorial Examples - v5.11, by Herong Yang
Archived: 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:
Table of Contents
JSP (JavaServer Pages) Overview
Tomcat Installation on Windows Systems
Syntax of JSP Pages and JSP Documents
JavaBean Objects and "useBean" Action Elements
Managing HTTP Response Header Lines
Non-ASCII Characters Support in JSP Pages
Overview of JSTL (JSP Standard Tag Libraries)
Multiple Tags Working Together
Using Tomcat on CentOS Systems
Connecting to SQL Server from Servlet
Developing Web Applications with Servlet
Archived: Installing GlassFish JSTL 1.2 on Tomcat
Archived: Downloading and Installing Tomcat 7
Archived: Installing Tomcat 5.5.7
Archived: Installing Tomcat 4.1.18
►Archived: Java Class Converted by Tomcat 4.1.18
Archived: Hijacking Servlet Converted from JSP
Archived: Using Perl LWP::Debug Module to Debug
Archived: Installing JSTL 1.0 Apache Implementation
Archived: Upgrade JDK 1.3 to JDK 1.4 on Tomcat 4.1
Archived: Compilation Errors with JDK 1.4