标签:alt oid tps jee servlet class code session head
手生就要多练啊。。。
package com.jeelearning.servlet; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; @WebServlet("/newSession") public class NewSession extends HttpServlet { private static final long serialVersionUID = 1L; protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setCharacterEncoding("utf-8"); response.setHeader("Content-type", "text/html;charset=utf-8"); PrintWriter out = response.getWriter(); out.println("测试Session属性<br/><br/>"); HttpSession session = request.getSession(); if (session.isNew()) { out.println("新朋友<br/><br/>"); } else { out.println("欢迎回来<br/><br/>"); } } }
标签:alt oid tps jee servlet class code session head
原文地址:http://www.cnblogs.com/aguncn/p/6512158.html