public static String getSessionId(HttpServletRequest req, HttpServletResponse resp){
        String id = null;
        if (req.getCookies() != null) {
            for (Cookie it : req.getCookies()) {
                if (COOKIE.equals(it.getName()))
                    id = it.getValue();
            }
        }
        if (id == null) {
            id = UUID.randomUUID().toString();
            Cookie cookie = new Cookie(COOKIE, id);
            cookie.setPath("/");
            resp.addCookie(cookie);
        }
        return id;
    }
public static String getSessionId ( HttpServletRequest req , HttpServletResponse resp ) { String id = null ; if ( req . getCookies ( ) != null ) { for ( Cookie it : req . getCookies ( ) ) { if ( COOKIE . equals ( it . getName ( ) ) ) id = it . getValue ( ) ; } } if ( id == null ) { id = UUID . randomUUID ( ) . toString ( ) ; Cookie cookie = new Cookie ( COOKIE , id ) ; cookie . setPath ( "/" ) ; resp . addCookie ( cookie ) ; } return id ; }
@param req
@param resp
@return