当前页面: 开发资料首页 → JSP 专题 → jsp研究(一)
摘要: jsp研究(一)
用jsp开发了程序好些时间了,但感觉对jsp的掌握还是不够。现在先分析一下*.jsp文件编译后的*_jsp.java 文件。
先写一个简单的my.jsp文件如下:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
<body>
hello
</body>
****************************************************************
把改文件方到 tomcat根目录\webapps\ROOT 下。
运行tomcat,在地址栏里输入http://localhost:8080/my.jsp
在 tomcat根目录\work\Catalina\localhost\_\org\apache\jsp 下就会生成my_jsp.java文件。
我们现在来看看这个文件:
package org.apache.jsp;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.sql.*;
public final class my_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent {
private static java.util.Vector _jspx_dependants;
public java.util.List getDependants() {
return _jspx_dependants;
}
public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException {
JspFactory _jspxFactory = null;
PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
JspWriter _jspx_out = null;
try {
_jspxFactory = JspFactory.getDefaultFactory();
response.setContentType("text/html; charset=gb2312");
pageContext = _jspxFactory.getPageContext(this, request, response,
"", true, 8192, true);
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
out.write("\r\n");
out.write(" HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"\r\n'>http://www.w3.org/TR/html4/loose.dtd\">\r\n");
out.write("\r\n");
out.write("<head>\r\n");
out.write("\r\n");
out.write("