1、<%
request.getRequestDispatcher("/public/head.jsp").include(request, response);
%> (动态包含)
<%@ include file="/public/head.jsp" %>(静态包含)
2、<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1" errorPage="/errors.jsp"%>(错误或者异常跳转
在开发时一定不能抛给用户,要给用户友好提示)
web.xml中也可以这样转:
<error-page><exception-type>(贴报的什么异常)</exception-type><location>/errors.jsp</location></error-page><error-page>
<error-code>404</error-code>
3、jsp九大隐式对象:(面试经常有)<location>/errors.jsp</location></error-page>
4、request:如果客户向服务器发送请求,产生数据用户看完就没用了,像这样的数据就存在request域;像新闻数据,用户看完就没用了;RequestResponseSessionApplication(servletcontext)Config(servletconfig)OutexceptionPage (servlet)Pagecontext printwriter jspwriter
session:如果客户向服务器发送请求,产生数据用户看完了等一会儿还有用,像这样的数据就存在session域;像购物数据,用户需要看到自己的购物信息,并且等一会还要用购物数据结账;
servletcontext:如果客户向服务器发送请求,产生数据用户看完了还要给其他用户用,像这样的数据就存在servletcontext域;像聊天数据;