web2.0年会回来

谢谢董璐的提示,我已经忘记了web2.0大会的消息。


我今天大会的收获是有幸认识了一位美女:中移动数据业务运营支持中心的任圆圆
另外一件事情是比较幸运的,结识了Pacific Epoch的Paul Waide。


Pacific Epoch的中文翻译是弘亚世代,他们的服务对象是投资商。

import jakarta.servlet.ServletException; import jakarta.servlet.annotation.WebServlet; import jakarta.servlet.http.*; import java.io.IOException; import java.net.URLDecoder; import java.net.URLEncoder; import java.text.SimpleDateFormat; import java.util.Date; /** * Servlet implementation class LastAccessServlet */ @WebServlet("/LastAccessServlet") public class LastAccessServlet extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public LastAccessServlet() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub response.setContentType("text/html;charset=utf-8"); Cookie[] cookies=request.getCookies(); boolean flag=false; if(cookies.length>0&&cookies!=null) { for(Cookie cookie:cookies) { String name=cookie.getName(); if("lastTime".equals(name)) { flag=true; String value=cookie.getValue(); System.out.println("解码前:"+value); value=URLDecoder.decode(value,"utf-8"); System.out.println("解码后:"+value); response.getWriter().write("欢迎回来,您上次访问时间"+"为:"+value); Date date=new Date(); SimpleDateFormat timesdf=new SimpleDateFormat("yyyy年MM"+"月dd日HH:mm:ss"); String str_time=timesdf.format(date); System.out.println("编码前:"+str_time); str_time=URLEncoder.encode(str_time,"utf-8"); System.out.println("编码后:"+str_time); cookie.setValue(str_time); cookie.setMaxAge(60*60*24*30); response.addCookie(cookie); break; } } if(cookies==null || cookies.length==0 || flag==false) { Date date=new Date(); SimpleDateFormat sdf=new SimpleDateFormat("yyyy年MM月dd日"+"HH:mm:ss"); String str_date=sdf.format(date); System.out.println("编码前:"+str_date); str_date=URLEncoder.encode(str_date,"utf-8"); Cookie cookie=new Cookie("lastTime",str_date); cookie.setMaxAge(60*60*24*30); response.addCookie(cookie); response.getWriter().write("您好,欢迎您首次访问"); } } } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } }
07-01
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值