How to Get Client IP Address in JSP Page

Get Client IP Address in JSP

In this example, We will show you simple program about, How to get client IP address in JSP page, When client give the request for the particular page in the web browser. This example were tested and output shared in the same post.

Example Program

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>What is my IP?</title>
</head>
<body>

	<%! String ipAddress; %>
	
	<%
		
		ipAddress = request.getRemoteAddr();
	
	%>

	<h1>Your IP Address : <%=ipAddress %></h1>

</body>
</html>

Output

How to Get Client IP Address in JSP