The approximate execution process of JSP files in Tomcat

Source: Internet
Author: User

1. in Tomcat's public settings
<Servlet>
<Servlet-Name>JSP</Servlet-Name>
<Servlet-class>Org. Apache. Jasper. servlet. jspservlet</Servlet-class>
........................
</Servlet>
<Servlet-mapping>
<Servlet-Name>JSP</Servlet-Name>
<URL-pattern>*. Jsp</Url-pattern>
</Servlet-mapping>
It can be seen that *. jsp files are all requestsOrg. Apache. Jasper. servlet. jspservlet.

2. Next let's take a look.Org. Apache. Jasper. servlet. jspservlet.
From the source code, we can see that this class inherits the httpservlet class and overwrites the main method.
Public void Service (httpservletrequest request,
Httpservletresponse response)
Throws servletexception, ioexception {
Find the path of the JSP file in this methodJspuriAnd execution MethodServicejspfile.
Then in the MethodServicejspfileWe can see that it creates a new classJspservletwrapperAnd executesServiceMethod.

3. Next, let's look at this class.Org. Apache. Jasper. servlet. jspservletwrapper
In this class
We can see that a new object is created during initialization.
Ctxt = new jspcompilationcontext (jspuri, taginfo, options,
Servletcontext, this, rctxt,
Tagfilejarurl );
Find a method
Public void Service (httpservletrequest request,
Httpservletresponse response,
Boolean precompile)
Throws servletexception, ioexception, filenotfoundexception
Here, we useCtxt. Compile(), Compiled the JSP file,
Call method againGetservlet ();To servlet type objectsTheservletAssignment,
Finally, call theservlet'sServiceMethod.
Java inheritance class converted from JSPHttpjspbaseWe can see from the class httpjspbase that the servcie method calls the _ jspservice method,

In this way, the _ jspservice method in Java converted by JSP is finally called..

We can ...... /Jakarta-tomcat-5.0.28/work/Catalina/localhost/bbsschool (project name)/org/Apache/jsp directory to find the Java source file converted from JSP, you can find the _ jspservice method.

*******************************

The 1 file is in the directory :... /Jakarta-tomcat-5.0.28/CONF/Web. xml

The Org. Apache. Jasper. servlet. jspservlet class mentioned in 2 is in the directory :... /Jakarta-tomcat-5.0.28/common/lib/jasper-compiler.rar. It contains compiled class files that can be downloaded online.

3. org. Apache. Jasper. servlet. jspservletwrapper is in the directory: Same as above.

********************************

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.