当前位置: 代码迷 >> Java Web开发 >> serverlet session 的有关问题,神奇至极啊,CDSN无能人乎?
  详细解决方案

serverlet session 的有关问题,神奇至极啊,CDSN无能人乎?

热度:271   发布时间:2016-04-17 00:47:42.0
serverlet session 的问题,神奇至极啊,CDSN无能人乎??!!
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吗?
  相关解决方案