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.
********************************