code012.jsp
1<%@ page language="java" contentType="text/html; charset=UTF-8" 2 pageEncoding="UTF-8"%> 3<!DOCTYPE html> 4<html> 5<head> 6<meta charset="UTF-8"> 7<title>Insert title here</title> 8</head> 9<body> 10<%-- 11 JSP内置对象 12 13 1.request 14 用于处理HTTP请求中的各项参数。 15 如,<a href = "delete.jsp?id=1">删除</a> 16 可以通过request对象的getParameter()方法获取 17 如,request.getParameter("id") 18 19 在请求转发时,需要把一些数据传递到转发后的页面处理。 20 就需要用到request的setAttribute()方法 21 如,request.setAttribute(String name,Object obj) 22 数据保存后,可以通过request的getAttribute()方法 23 获取变量的值 24 如,request.getAttribute(String name) 25 26 cookie以key value的形式保存数据到客户机上。 27 可以使用getCookies()方法获取集合,通过 28 getName获取cookie名称;通过getValue() 29 获取对象的值。在向cookie中保存中文时,需要用 30 java.net.URLEncoder类的encode()方法将保存的 31 cookie信息编码。从cookie读取是,需要使用 32 URLDecoder类的decode方法解码。 33 34 35 36 37 38 --%> 39</body> 40</html>