默认情况下
C:\Users\<用户名>\.IntelliJIdea2019.1\system\tomcat
\项目名\work\Catalina\localhost\项目名\org\apache\jsp\
index_jsp.java
/*
* Generated by the Jasper component of Apache Tomcat
* Version: Apache Tomcat/7.0.62
* Generated at: 2019-08-10 05:14:19 UTC
* Note: The last modified time of this file was set to
* the last modified time of the source file after
* generation to assist with modification tracking.
*/
package org.apache.jsp;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.util.Date;
import java.text.SimpleDateFormat;
import com.web.Person;
import java.util.ArrayList;
public final class index_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent {
private static final javax.servlet.jsp.JspFactory _jspxFactory =
javax.servlet.jsp.JspFactory.getDefaultFactory();
private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants;
private javax.el.ExpressionFactory _el_expressionfactory;
private org.apache.tomcat.InstanceManager _jsp_instancemanager;
public java.util.Map<java.lang.String,java.lang.Long> getDependants() {
return _jspx_dependants;
}
public void _jspInit() {
_el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
_jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig());
}
public void _jspDestroy() {
}
public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response)
throws java.io.IOException, javax.servlet.ServletException {
final javax.servlet.jsp.PageContext pageContext;
javax.servlet.http.HttpSession session = null;
final javax.servlet.ServletContext application;
final javax.servlet.ServletConfig config;
javax.servlet.jsp.JspWriter out = null;
final java.lang.Object page = this;
javax.servlet.jsp.JspWriter _jspx_out = null;
javax.servlet.jsp.PageContext _jspx_page_context = null;
try {
response.setContentType("text/html;charset=UTF-8");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
out.write("\n");
out.write("\n");
out.write("\n");
out.write("\n");
out.write("\n");
out.write("\n");
out.write("<html>\n");
out.write(" <head>\n");
out.write(" <title>$Title$</title>\n");
out.write(" </head>\n");
out.write(" <body>\n");
out.write(" $END$\n");
out.write(" <div>\n");
out.write("\n");
out.write("\n");
out.write(" ");
String s="A";
int i=10;
Date date=new Date();
String now=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(date);
//创建自定义对象
Person person=new Person();
person.setName("小王");
person.setAge(10);
//将对象放入内置request容器中
request.setAttribute("person",person);
String name=person.getName();
int age=person.getAge();
//创建一个arrayList集合,将集合放入request容器中
ArrayList<String> arrayList = new ArrayList<String>();
arrayList.add("a");
arrayList.add("b");
request.setAttribute("_arrayList",arrayList);
out.write('\n');
out.write("\n");
out.write(" <div>\n");
out.write(" 第一种方式,向页面输出: ");
out.print(s );
out.write("\n");
out.write(" </div>\n");
out.write(" <div>\n");
out.write(" 当前时间:");
out.print(now );
out.write("\n");
out.write(" </div>\n");
out.write(" <div>\n");
out.write(" 姓名:");
out.print(name );
out.write("<br>\n");
out.write(" 密码:");
out.print(age );
out.write("\n");
out.write(" </div>\n");
out.write(" <div>\n");
out.write(" <div>使用el表达式输出</div>\n");
out.write(" <div>\n");
out.write(" 姓名:");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${person.name }", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false));
out.write("<br>\n");
out.write(" 密码:");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${person.age }", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false));
out.write("\n");
out.write(" </div>\n");
out.write(" </div>\n");
out.write(" <div>\n");
out.write(" 第二种方式,向页面输出:");
out.println(s);
out.write("\n");
out.write(" </div>\n");
out.write(" <div>\n");
out.write(" ArrayList输出 ");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${_arrayList[0]}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false));
out.write("<br>\n");
out.write(" ArrayList输出 ");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${_arrayList[1]}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false));
out.write("\n");
out.write(" </div>\n");
out.write("\n");
out.write("\n");
out.write(" </div>\n");
out.write(" </body>\n");
out.write("</html>\n");
} catch (java.lang.Throwable t) {
if (!(t instanceof javax.servlet.jsp.SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
try {
if (response.isCommitted()) {
out.flush();
} else {
out.clearBuffer();
}
} catch (java.io.IOException e) {}
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
else throw new ServletException(t);
}
} finally {
_jspxFactory.releasePageContext(_jspx_page_context);
}
}
}
对应的index.jsp代码(进行比较)
<%@ page import="java.util.Date" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="com.web.Person" %>
<%@ page import="java.util.ArrayList" %>
<%--
Created by IntelliJ IDEA.
User: 四两数字先生
Date:
Time:
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>$Title$</title>
</head>
<body>
$END$
<div>
<%
String s="A";
int i=10;
Date date=new Date();
String now=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(date);
//创建自定义对象
Person person=new Person();
person.setName("小王");
person.setAge(10);
//将对象放入内置request容器中
request.setAttribute("person",person);
String name=person.getName();
int age=person.getAge();
//创建一个arrayList集合,将集合放入request容器中
ArrayList<String> arrayList = new ArrayList<String>();
arrayList.add("a");
arrayList.add("b");
request.setAttribute("_arrayList",arrayList);
%>
<%-- out 对象是 javax.jsp.servlet.JspWriter 的实例
作用:向页面输出信息
内置对象系统帮你自动创建一个实例,等价于如下
JspWriter out=new JspWriter();
--%>
<div>
第一种方式,向页面输出: <%=s %>
</div>
<div>
当前时间:<%=now %>
</div>
<div>
姓名:<%=name %><br>
密码:<%=age %>
</div>
<div>
<div>使用el表达式输出</div>
<div>
姓名:${person.name }<br>
密码:${person.age }
</div>
</div>
<div>
第二种方式,向页面输出:<%out.println(s);%>
</div>
<div>
ArrayList输出 ${_arrayList[0]}<br>
ArrayList输出 ${_arrayList[1]}
</div>
</div>
</body>
</html>