欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

JSP设置和获取Cookie代码,jspcookie代码,<%@ page con

来源: javaer 分享于  点击 42524 次 点评:16

JSP设置和获取Cookie代码,jspcookie代码,<%@ page con


<%@ page contentType=“text/html;charset=gb2312″%><%@ page isELIgnored=“false” %><html>    <head>       <title>response测试3-1</title>    </head>    <body>       姓名:<%=request.getParameter(“username”) %><br>       年龄:<%=request.getParameter(“age”) %><br>       <%           String username = request.getParameter(“username”);           String age = request.getParameter(“age”);           Cookie c1 = new Cookie(“username”,username);           Cookie c2 = new Cookie(“age”,age);           c1.setMaxAge(24*3600);           c2.setMaxAge(24*3600);           response.addCookie(c1);           response.addCookie(c2);        %>    </body></html>
                                获取cookie的jsp页面
<%@ page contentType=“text/html;charset=gb2312″%><%@ page isELIgnored=“false” %><html>    <head>       <title>response测试3-2</title>    </head>    <body>       <%           Cookie[] cookies = request.getCookies();           for(Cookie c:cookies)           {              out.println(c.getName()+” “+c.getValue()+”<br>”);           }        %>    </body></html>
相关栏目:

用户点评