Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-424

request.getRequestedSessionId() when creating new session, it returns id of current session instead of null

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 1.2.3.Final
    • None
    • Servlet
    • None

      When in servlet I create new session and ask for requested session id request.getRequestedSessionId(), for new client it returns id of newly created session instead of null (client didn't specify any session Id).

      @WebServlet(name="SessionTimeoutCheck", urlPatterns={"/SessionTimeoutCheck"})
      public class SessionTimeoutCheckServlet extends HttpServlet {
      
          @Override
          protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              HttpSession session = request.getSession();
              response.setContentType("text/html");
      
              PrintWriter out = response.getWriter();
              out.write("Requested session ID " + request.getRequestedSessionId());
              out.write("<br />");
              if (request.getRequestedSessionId() != null) {
                  if (request.isRequestedSessionIdValid()) {
                      out.write("Valid session");
                  } else {
                      out.write("Session expired");
                  }
              } else {
                  out.write("No sessionId specified => new session");
              }
          }
      }
      
      

            sdouglas1@redhat.com Stuart Douglas
            rhatlapa@redhat.com Radim Hatlapatka (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: