Supporting Sessions Without Cookies in Tomcat

后端 未结 5 1040
我寻月下人不归
我寻月下人不归 2020-12-01 06:58

I am currently running an application with the following properties:

  • Java-based with Spring and Acegi
  • Running on Tomcat 5

I need the ab

5条回答
  •  天命终不由人
    2020-12-01 07:32

    Best way is to use URL rewriting . So, when you use request.getSession() ,the container will send "Set-Cookie" header for session-id in HTTP-response as well as session-id appended to URL (but you must use response.encodeURL(session_info) for url rewriting).

    public void doGet(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException  {
        resp.setContentType("text/html");
        PrintWriter pw=resp.getWriter();
        HttpSession session=req.getSession();
        pw.println("");
        pw.println("Click");
        pw.println("");
    
    }
    

提交回复
热议问题