See HttpServletRequest#getQueryString()
If you want the whole string, you’ll have to append the request url and the query string together as there is no method to get the whole thing.
System.out.println(request.getRequestURL().append('?').append(request.getQueryString()));