I have been using the following 3 ways to access the query parameters in the URL.
JSP
String success = request.getParameter("success");
if(success!=null) {
//do something
}
JSTL
<c:if test="${not empty param.success}">
//do something
</c:if>
JavaScript
function getQueryParameter ( parameterName ) {
var queryString = window.top.location.search.substring(1);
var parameterName = parameterName + "=";
if ( queryString.length > 0 ) {
begin = queryString.indexOf ( parameterName );
if ( begin != -1 ) {
begin += parameterName.length;
end = queryString.indexOf ( "&" , begin );
if ( end == -1 ) {
end = queryString.length
}
return unescape ( queryString.substring ( begin, end ) );
}
}
return "null";
}
All 3 of these work for me, but I would like to know if there is any of these has any issue and which one is preferred?