1.request
<html>
<head>
<title>孟红旭</title>
</head>
<body>
<form action="index1.jsp" method="post">
username:<input type="text" name="user"/><br/>
password:<input type="password" name="pwd"/><br/>
<input type="checkbox" name="likes" value="羽毛球">羽毛球
<input type="checkbox" name="likes" value="摄影">摄影
<input type="checkbox" name="likes" value="音乐">音乐
<br/>
<input type="submit" name="登陆"/>
</form>
</body>
</html>
2.response
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>孟红旭</title>
</head>
<body>
<%
request.setCharacterEncoding("UTF-8");
String name = request.getParameter("user");
String pwd = request.getParameter("pwd");
System.out.println(name+","+pwd);
if("meng".equals(name) && "101016".equals(pwd)) { out.println("登陆成功");
request.setAttribute("age", "22岁");
request.getRequestDispatcher("response.jsp").forward(request, response);
}else{
response.setCharacterEncoding("UTF-8");
response.setContentType("textml;charset=UTF-8");
response.sendRedirect("response.jsp");
}
%>
</body>
</html>
<html>
<head>
<title>孟红旭</title>
</head>
<body>
不好意思,登陆失败
</body>
</html>
3.out
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>孟红旭</title>
</head>
<body>
<%
out.print("你好whd");
out.flush();
out.println("缓冲区空间:" + out.getBufferSize());
out.print("剩余空间:" + out.getRemaining());
out.print("AutoFlush状态:" + out.isAutoFlush());
out.close();
%>
</body>
</html>
4.session
<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
<base href="<%=basePath%>">
<title>孟红旭</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<form id="form1" name="form1" method="post" action="session2.jsp">
<div align="center">
<table width="40%" border="0">
<tr>
<td width="36%"><div align="center">您的名字是:</div></td>
<td width="64%">
<label>
<div align="center">
<input type="text" name="name" />
</div>
</label>
</td>
</tr>
<tr>
<td colspan="2">
<label>
<div align="center">
<input type="submit" name="Submit" value="提交" />
</div>
</label>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
5.pageContext
%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>孟红旭</title>
</head>
<body>
<form action="<%=request.getContextPath()%>/session.jsp" method="post">
username:<input type="text" name="user"/><br/>
password:<input type="password" name="pwd"/><br/>
<input type="checkbox" name="likes" value="羽毛球">羽毛球
<input type="checkbox" name="likes" value="摄影">摄影
<input type="checkbox" name="likes" value="音乐">音乐
<br/>
<input type="submit" name="登陆"/>
</form>
<h2>pageContext对象</h2>
<%
pageContext.getRequest();
pageContext.getResponse();
pageContext.getSession();
pageContext.getOut();
String path = request.getContextPath();
out.println("当前上下文的绝对路径:"+path);
%>
</body>
</html>
6.application
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>孟红旭</title>
</head>
<body>
<body>
<%
Object obj=application.getAttribute("counter");
if (obj==null){
application.setAttribute("counter",new Integer(1));
out.println("该页面被访问了1次<br/>");
}else {
int countValue=new Integer(obj.toString());
countValue++;
out.println("该页面被访问了"+countValue+"次<br/>");
application.setAttribute("counter",countValue);
}
%>
</body>
</body>
</html>
7.page
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>孟红旭</title>
</head>
<body>
<%! Object object;
<ul>
<li>getclass()方法的返回值:<%=page.getClass()%></>li>
<li>hashcode()方法的返回值:<%=page.hashCode()%></>li>
<li>tostring()方法的返回值:<%=page.toString()%></>li>
<li>与object对象比较的返回值:<%=page.equals(object)%></>li>
<li>与this对象比较的返回值:<%=page.equals(this)%></>li>
</ul>
</body>
</html>
8.confit
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>孟红旭</title>
</head>
<body>
<%
String url = config.getInitParameter("url");
String str = config.toString();
out.print("page对象的initParameter方法:"+url+"</br>");
out.print("page对象的toString方法:"+str);
%>
</body>
</html>