I am having trouble retrieving the origin IP address from the httpRequest object using the JavaScript code below. The xhttp.responseText is returning a null value. Any assistance would be greatly appreciated.
<script type="text/javascript" language="JavaScript">
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 0) {
document.getElementById("LOCAL_IP").value = xhttp.responseText;
}
};
xhttp.open("GET", "http://11.5.2.218:4080/getIP.jsp", true);
xhttp.send();
</script>
The content of the getIP.jsp file is as follows:
Your IP is <%=request.getRemoteAddr()%>