JSP Research (i)

Source: Internet
Author: User
Tags config root directory tomcat
JS with JSP developed a program for a lot of time, but the feeling of the master of JSP is still not enough. Now let's analyze the *_jsp.java file after the *.jsp file is compiled.
First write a simple my.jsp file as follows:

<%@ page contenttype= "text/html; charset=gb2312 "language=" java "import=" java.sql.* "errorpage=" "%>"
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title>baiming</title>

<body>
Hello
</body>
****************************************************************
Change the file side to the Tomcat root directory \webapps\root.
Run Tomcat, enter http://localhost:8080/my.jsp in the address bar
The My_jsp.java file is generated under the Tomcat root directory \work\catalina\localhost\_\org\apache\jsp.
Let's look at this file now:
Package org.apache.jsp;

Import javax.servlet.*;
Import javax.servlet.http.*;
Import javax.servlet.jsp.*;
Import java.sql.*;

Public final class My_jsp extends Org.apache.jasper.runtime.HttpJspBase
Implements Org.apache.jasper.runtime.JspSourceDependent {

private static Java.util.Vector _jspx_dependants;

Public Java.util.List getdependants () {
return _jspx_dependants;
}

public void _jspservice (HttpServletRequest request, httpservletresponse response)
Throws Java.io.IOException, Servletexception {

Jspfactory _jspxfactory = null;
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=gb2312 ");
PageContext = _jspxfactory.getpagecontext (this, request, response,
"", True, 8192, true);
application = Pagecontext.getservletcontext ();
Config = Pagecontext.getservletconfig ();
Session = Pagecontext.getsession ();
out = Pagecontext.getout ();
_jspx_out = out;

Out.write ("\ r \ n");
Out.write ("<! DOCTYPE HTML public \-//w3c//dtd HTML 4.01 transitional//en\ "\" http://www.w3.org/tr/html4/loose.dtd\ ">\r\n");
Out.write ("Out.write ("Out.write ("<meta http-equiv=\" content-type\ "content=\" text/html; charset=gb2312\ ">\r\n");
Out.write ("<title>baiming</title>\r\n");
Out.write ("Out.write ("\ r \ n");
Out.write ("<body>\r\n");
Out.write ("hello\r\n");
Out.write ("</body>\r\n");
Out.write ("catch (Throwable t) {
if (!) ( T instanceof Skippageexception)) {
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 find 8 hidden objects used in the JSP.





Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.