201819102024包丽荣
config
主要是取得服务器的配置信息
page
主要处理请求。
Application的代码
注册成功
<%
int count =0;
application.setAttribute("account",++count);
out.print(session.getAttribute("username"));
out.print(request.getAttribute("user"));
out.print(application.getAttribute("account"));
%>
out的代码
out 对象用于在Web浏览器内输出信息,并且管理应用服务器上的输出缓冲区。
<%
out.print("201819102024");
out.print("包丽荣");
%>
内置对象Request
request对象代表了电脑客户端的请求信息,是接受信息传送到电脑服务器的数据。
<form action="request-receiver.jsp">
username:<input type="text" name="user"/><br/>
password:<input type="password" name="pwd"/><br/>
<input type="submit" name="登陆"/>
</form>
内置对象resonpse
response 代表的是对客户端的响应,主要是负责将电脑处理过的对象在传回到客户端。
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
不好意思,登陆失败。
<body>
session(会话)
session对象是服务器自动创建的与用户请求对象,来保存用户信息的。
<form action="<%=request.getContextPath()%>/session.jsp" method="post">
username:<input type="text" name="user"/><br/>
password:<input type="password" name="pwd"/><br/>
<input type="submit" name="登陆"/>
</form>
<h2>pageContext对象</h2>
pageContext.getRequest();
pageContext.getResponse();
pageContext.getSession();
pageContext.getOut();
String path = request.getContextPath();
out.println("当前上下文的绝对路径:"+path);
%>
Exception
exception 对象是显示异常信息。
<%
int[] num = {9,2,3,2,8};
for(int i =0;i<=num.length;i++){
out.println(num[i]);
}
%>