So I\'m trying to grab the current URL of the page using Java\'s request object. I\'ve been using request.getRequestURI() to preform this, but I noticed that when a java cla
Just did a slight tidy of the solution by Ballsacian1
String currentURL = null;
if( request.getAttribute("javax.servlet.forward.request_uri") != null ){
currentURL = (String)request.getAttribute("javax.servlet.forward.request_uri");
}
if( currentURL != null && request.getAttribute("javax.servlet.include.query_string") != null ){
currentURL += "?" + request.getQueryString();
}
The null checks are going to run a lot more efficiently than String comparisons.