serverlet里面写session,另一个里面取不到值?!!
serverlet A:
public class SessionA extends HttpServlet{
public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException{
request.getSession().setAttribute("rand", "ddddd");
}
}
serverlet B:
public class SessionB extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try{
request.setCharacterEncoding("UTF-8");
response.setHeader("Charset","UTF-8");
response.setContentType("text/html;charset=GBK");
PrintWriter out =response.getWriter();
HttpSession session = request.getSession();
String value =(String) session.getAttribute("rand");
System.out.println("rand="+value);............
打印出来rand=null!!!!!!
这是怎么回事??求解??!!!
------解决方案--------------------
你访问过ServletA吗?