◎ HttpSession接口方法使用示例
在Session中保存数据,在其他Servlet中获取.
⑥ServletA中的关键代码 *
HttpSession 目芒SMion等equ& (七rn皂):;
◎ HttpSession接口方法使用示例
在Session中保存数据,在其他Servlet中获取.
⑥ServletA中的关键代码 *
HttpSession 目芒SMion等equ& (七rn皂):;
String sessianld={);
session * setAttribute("name"f "accp");
("sessionld", sessionld); response . sendRedirect (''ServletB");
◎ HttpSession接口方法使用示例
奥Se「vletB中豹关键代鸽
HttpSession sess±on=reqri^5t xgetSession ();
String naime=sessiQn . getAttribute (r*n^me11) . toString ();
String sessionId="} .toString{) response x se tContentType (" text/html11};
PrintWritei? out = response,getWriter (J ;
out. printin (ri < f DOCTYFE HTML PUBLIC \rr-//W3C//DTD HTML Transitional//EN\T>");
out. printin ( " <HTML>dl);
out .pj:intln(ir <HEADXTITLE>A Servlet</TITLEx/HEAD>ir);
out . printin (Tr <BODY>Tr);
out. print f name is 11};
(name);
out. print <br>s ess ion Id is ;
(sessionld);
outbprint;ln ( " </BOD¥>n );
out. printin (ir</HTML>,1) /
out. flush ();
out. close 11 :
◎ HttpSession接口方法使用示例
® 「vletB
已rvlet>
<servletuname>ServletA</servlet-name>
<serviet-class>!.ServletA</5ervlet-class>
</servlet>
<servlet>
<servlet-name>Sei:vletB</seirvrle t-name>
<servLet-class>!.Servlet
HttpSession接口使用方法 来自淘豆网m.daumloan.com转载请标明出处.