I cannot get the origin IP address from the httpRequest object using the following JavaScript. xhttp.responseText return a null value. I'd appreciate your help.
<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 getIP.jsp file content is
Your IP is <%=request.getRemoteAddr()%>