首先在啟用 cookies 的情況下運行。然后關閉對 cookie 的支持,重啟瀏覽器,再運行一次。每次你都可以看到會話管理在起作用,并能在頁之間傳遞信息。
注意,如果你想讓這個例子能在關閉了 cookies 的瀏覽器中工作,你的 JSP 引擎必須支持 URL 重寫。
hello1.jsp
%@ page session="true" %> % Integer num = new Integer(100); session.putValue("num",num); String url =response.encodeURL("hello2.jsp"); %> a href='%=url%>'>hello2.jsp/a>
hello2.jsp
%@ page session="true" %> % Integer i= (Integer)session.getValue("num"); out.println("Num value in session is "+i.intValue()); %>
axeon于2000-08-03 11:05:38發送 Copyright copy; 2000 www.jsper.com All rights reserved. The catalog script used on this site was written by axeon 站務聯系: [axeonOICQ:1684897 ICQ:75795533]