Servlet随笔

Posted 薰衣草

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Servlet随笔相关的知识,希望对你有一定的参考价值。

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;
}

  

 

以上是关于Servlet随笔的主要内容,如果未能解决你的问题,请参考以下文章

Servlet随笔

20160928随笔

Servlet随笔

Servlet随笔

servlet相关随笔,API

JavaWeb学习随笔