jsp内置对象request使用方法2

<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Date"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>


<%
int a =1;
int b =2;
request.setAttribute("ab", a);
request.setAttribute("b", b);



%>
<jsp:forward page="top.jsp"/>
</body>

</html>
<%@page import="java.text.SimpleDateFormat"%>

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<% 



System.out.println(request.getAttribute("ab"));
System.out.println(request.getAttribute("b"));

String b = request.getAttribute("b").toString();
%>
<%=request.getAttribute("b")%>
<%=b %>
</body>
</html>

 

posted @ 2016-12-09 20:35  wangguoning  阅读(284)  评论(0编辑  收藏  举报