HttpServlet中的getRequestURL、getRequestURI、getContextPath方法获取的字符串为
jsp文件会被编译成一个Servlet,该Servlet继承自HttpJspBase,该Servlet中的_jspService方法的部分代码如下
login.jsp被编译成login_jsp类
HttpJspPage接口中的方法如下
抽象类HttpJspBase实现了HttpJspPage接口
package org.apache.jasper.runtime; import java.io.IOException; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.jsp.HttpJspPage; import org.apache.jasper.compiler.Localizer; public abstract class HttpJspBase extends HttpServlet implements HttpJspPage { private static final long serialVersionUID = 1L; protected HttpJspBase() { } @Override public final void init(ServletConfig config) throws ServletException { super.init(config); jspInit(); _jspInit(); } @Override public String getServletInfo() { return Localizer.getMessage("jsp.engine.info"); } @Override public final void destroy() { jspDestroy(); _jspDestroy(); } @Override public final void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { _jspService(request, response); } @Override public void jspInit() { } public void _jspInit() { } @Override public void jspDestroy() { } protected void _jspDestroy() { } @Override public abstract void _jspService(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException; }