JSP编译过程

一、项目部署在web容器后(tomcat 注意tomcat是web容器,只是带有一少部分http服务器的功能)

                          1.客户端发送请求给web容器

                          2.web容器将jsp首先转译成servlet.java(jsp本质上就是servlet)

                          3.web容器将servlet.java代码编译成class文件

                          4.web容器加载class文件

                          5.web容器将结果响应给客户端

二、Jsp编译成.class文件源代码

                          1.jsp本质上也是servlet,中间仍存在service等方法,用来处理servlet或其他jsp传来的request、response对象。通过PrintWriter out=response.getWriter();对象直接向客户端输出字符串

                          2.附class文件源代码:

package org.apache.jsp;

import java.io.IOException;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.el.ExpressionFactory;
import javax.servlet.DispatcherType;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspFactory;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.SkipPageException;
import org.apache.jasper.runtime.HttpJspBase;
import org.apache.jasper.runtime.InstanceManagerFactory;
import org.apache.jasper.runtime.JspSourceDependent;
import org.apache.jasper.runtime.JspSourceImports;
import org.apache.tomcat.InstanceManager;

public final class index_jsp extends HttpJspBase implements JspSourceDependent, JspSourceImports {
    private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();
    private static Map<String, Long> _jspx_dependants;
    private static final Set<String> _jspx_imports_packages = new HashSet();
    private static final Set<String> _jspx_imports_classes;
    private volatile ExpressionFactory _el_expressionfactory;
    private volatile InstanceManager _jsp_instancemanager;

    static {
        _jspx_imports_packages.add("javax.servlet");
        _jspx_imports_packages.add("java.util");
        _jspx_imports_packages.add("javax.servlet.http");
        _jspx_imports_packages.add("javax.servlet.jsp");
        _jspx_imports_classes = null;
    }

    public index_jsp() {
    }

    public Map<String, Long> getDependants() {
        return _jspx_dependants;
    }

    public Set<String> getPackageImports() {
        return _jspx_imports_packages;
    }

    public Set<String> getClassImports() {
        return _jspx_imports_classes;
    }

    public ExpressionFactory _jsp_getExpressionFactory() {
        if (this._el_expressionfactory == null) {
            synchronized(this) {
                if (this._el_expressionfactory == null) {
                    this._el_expressionfactory = _jspxFactory.getJspApplicationContext(this.getServletConfig().getServletContext()).getExpressionFactory();
                }
            }
        }

        return this._el_expressionfactory;
    }

    public InstanceManager _jsp_getInstanceManager() {
        if (this._jsp_instancemanager == null) {
            synchronized(this) {
                if (this._jsp_instancemanager == null) {
                    this._jsp_instancemanager = InstanceManagerFactory.getInstanceManager(this.getServletConfig());
                }
            }
        }

        return this._jsp_instancemanager;
    }

    public void _jspInit() {
    }

    public void _jspDestroy() {
    }

    public void _jspService(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        String _jspx_method = request.getMethod();
        if (!"GET".equals(_jspx_method) && !"POST".equals(_jspx_method) && !"HEAD".equals(_jspx_method) && !DispatcherType.ERROR.equals(request.getDispatcherType())) {
            response.sendError(405, "JSPs only permit GET POST or HEAD");
        } else {
            JspWriter out = null;
            JspWriter _jspx_out = null;
            PageContext _jspx_page_context = null;

            try {
                response.setContentType("text/html; charset=utf-8");
                PageContext pageContext = _jspxFactory.getPageContext(this, request, response, (String)null, true, 8192, true);
                _jspx_page_context = pageContext;
                pageContext.getServletContext();
                pageContext.getServletConfig();
                pageContext.getSession();
                out = pageContext.getOut();
                out.write(13);
                out.write(10);
                String path = request.getContextPath();
                String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
                out.write("\r\n");
                out.write("\r\n");
                out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\r\n");
                out.write("<html>\r\n");
                out.write("  <head>\r\n");
                out.write("    <base href=\"");
                out.print(basePath);
                out.write("\">\r\n");
                out.write("    \r\n");
                out.write("    <title>管理员登录界面</title>\r\n");
                out.write("\t<meta http-equiv=\"pragma\" content=\"no-cache\">\r\n");
                out.write("\t<meta http-equiv=\"cache-control\" content=\"no-cache\">\r\n");
                out.write("\t<meta http-equiv=\"expires\" content=\"0\">    \r\n");
                out.write("\t<meta http-equiv=\"keywords\" content=\"keyword1,keyword2,keyword3\">\r\n");
                out.write("\t<meta http-equiv=\"description\" content=\"This is my page\">\r\n");
                out.write("\t<!--\r\n");
                out.write("\t<link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\">\r\n");
                out.write("\t-->\r\n");
                out.write("\t<link href=\"css/biaodan.css\"  rel=\"stylesheet\"  type=\"text/css\"/>\r\n");
                out.write("  </head>\r\n");
                out.write("  \r\n");
                out.write(" \r\n");
                out.write("<body>\r\n");
                out.write("\t\t<img src=\"img/新闻框.jpg\" class=\"img1\">\r\n");
                out.write("\t\t<div class=\"div15\">\r\n");
                out.write("\t\t<h1>管理员登录界面</h1>\r\n");
                out.write("\t\t</div>\r\n");
                out.write("\t\t<form action=\"/news/UserServlet\" method=\"post\" class=\"form2\">\r\n");
                out.write("\t\t\t<div class=\"div1\">\r\n");
                out.write("\t\t\t&nbsp;&nbsp;&nbsp;姓名:<input type=\"text\" id=\"name\" name=\"loginName\"/><span>   (不少于2个字符)</span><br>\r\n");
                out.write("\t\t\t&nbsp;&nbsp;&nbsp;密码:<input type=\"password\" id=\"password\" name=\"password\"/><span>   (不少于6个字符)</span><br>\r\n");
                out.write("\t\t\t 手机号:<input  id=\"tel\"/><span>   (输入11位手机号码)</span><br/>  \r\n");
                out.write("\t\t  \t\t\t\t<table> \r\n");
                out.write("\t\t\t\t\t<tr>\r\n");
                out.write("\t\t\t\t\t\t<td></td>   \r\n");
                out.write("\t\t\t\t\t\t<td>\r\n");
                out.write("\t\t\t\t\t\t\t<br><div class=\"code\" id=\"checkCode\" onclick=\"createCode()\" ></div>\r\n");
                out.write("\t\t\t\t\t\t</td> \r\n");
                out.write("\t\t\t\t\t\t\r\n");
                out.write("\t\t\t\t\t\t<td><a href=\"#\" onclick=\"createCode()\"><p class=\"p4\">看不清换一张<p></a></td>   \r\n");
                out.write("\t\t\t\t\t</tr> \r\n");
                out.write("\t\t\t\t\t</br>\r\n");
                out.write("\t\t\t\t\t\r\n");
                out.write("\t\t\t\t\t<tr>     \r\n");
                out.write("\t\t\t\t\t\t<td>验证码:</td>   \r\n");
                out.write("\t\t\t\t\t\t<br>\r\n");
                out.write("\t\t\t\t\t\t<td><input style=\"position:absolute left:10px\" type=\"text\"  id=\"inputCode\" /> </td>     \t\t\t\t\t\t\r\n");
                out.write("\t\t\t\t\t\t <td><input id=\"Button1\" onclick=\"validateCode();\" type=\"button\" value=\"确定\" /></td>\r\n");
                out.write("\t\t\t\t\t\t</tr>\r\n");
                out.write("\t\t\t\t  </table> \r\n");
                out.write("\t        </div>\r\n");
                out.write("\t      <input class=\"button\" type=\"submit\" onclick=\"check()\" value=\"登录\"/>\r\n");
                out.write("\t\t </form> \r\n");
                out.write("\t\t \r\n");
                out.write("\t\t<br>\r\n");
                out.write("\t\t  \r\n");
                out.write("\t\t  \r\n");
                out.write("\r\n");
                out.write("\t\t\r\n");
                out.write("\t     <script src=\"js/biaodan.js\"></script>\r\n");
                out.write("\t </body>\r\n");
                out.write("</html>\r\n");
            } catch (Throwable var15) {
                if (!(var15 instanceof SkipPageException)) {
                    out = (JspWriter)_jspx_out;
                    if (_jspx_out != null && ((JspWriter)_jspx_out).getBufferSize() != 0) {
                        try {
                            if (response.isCommitted()) {
                                out.flush();
                            } else {
                                out.clearBuffer();
                            }
                        } catch (IOException var14) {
                            ;
                        }
                    }

                    if (_jspx_page_context == null) {
                        throw new ServletException(var15);
                    }

                    _jspx_page_context.handlePageException(var15);
                }
            } finally {
                _jspxFactory.releasePageContext(_jspx_page_context);
            }

        }
    }
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值