jsp常用内置对象:
request:请求
response :响应
pageContext:页面上下文(当前页面)
session:会话
out:输出对象
application:应用程序上下文(整个程序)
servlet中request和response内置对象已经在doGet()/doPost()方法中声明,可以直接使用。
其他的可以参考下面进行创建。
public class mysvt extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
/*获取pageContext内置对象*/
/*
* 7个参数分别是
* 代表当前Servlet本身
* request
* response
* 是否指定错误页面
* 是否需要session
* 8192缓冲区大小
* true,是否缓冲
*/
PageContext pageContext = JspFactory.getDefaultFactory()
.getPageContext(this, request, response, null, true, 8019, true);
/*获取session内置对象*/
HttpSession session = request.getSession();
/*获取out内置对象*/
PrintWriter writer = response.getWriter();
/*获取application内置对象*/
ServletContext application = this.getServletContext();
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request,response);
}
}