P. 1
Basic Java EE Book

Basic Java EE Book

|Views: 209|Likes:

More info:

Published by: Kondalarao Suravarapu on May 20, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

11/20/2012

pdf

text

original

106

11 - JSP

Even if we start with a very benign java server page, like the listed “hello world” example below,
the generated servlet is still pretty complex.
First, the original index.jsp file.

<%--

Document : index
Created on : 08.11.2010, 08:17:39
Author : sm

--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
"http://www.w3.org/TR/html4/loose.dtd">

JSP Page


Hello World!

The generated servlet follows.

package org.apache.jsp;

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

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

private static final JspFactory _jspxFactory =
JspFactory.getDefaultFactory();

private static java.util.Vector _jspx_dependants;

private org.glassfish.jsp.api.ResourceInjector
_jspx_resourceInjector;

public Object getDependants() {

107

11 - JSP

return _jspx_dependants;

}

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

PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
JspWriter _jspx_out = null;
PageContext _jspx_page_context = null;

try {

response.setContentType("text/html;charset=UTF-8");
response.setHeader("X-Powered-By", "JSP/2.1");
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;
_jspx_resourceInjector =
(org.glassfish.jsp.api.ResourceInjector)
application.getAttribute("com.sun.appserv.jsp.resource.injector");

out.write("\n");
out.write("\n");
out.write("\n");
out.write("

Transitional//EN\"\n");

out.write(" \"http://www.w3.org/TR/html4/loose.dtd\">\n");
out.write("\n");
out.write("\n");
out.write(" \n");
out.write(" content=\"text/html; charset=UTF-8\">\n");
out.write(" JSP Page\n");
out.write(" \n");
out.write(" \n");
out.write("

Hello World!

\n");
out.write(" \n");
out.write("\n");

108

11 - JSP

} catch (Throwable t) {
if (!(t instanceof SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
out.clearBuffer();
if (_jspx_page_context != null)
_jspx_page_context.handlePageException(t);
else throw new ServletException(t);

}
} finally {

_jspxFactory.releasePageContext(_jspx_page_context);

}

}

}

A short comment. The class HttpJspBase is a vendor-implemented class, whose declaration
clarifies its relationship with the standard JSP classes and interfaces.

public abstract class HttpJspBase extends
javax.servlet.http.HttpServlet implements javax.servlet.jsp.HttpJspPage

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->