I am trying to get the ip of the system which is view my jsp page. it works fine when the client system was windows.But in linux it is not working.I am using the following code to do this. can any one suggest me to fix my problem

code:

Mac.jsp

```
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="mc" method="post">
<input type="submit" value="Send">
 <p>Your IP address is: ${pageContext.request.remoteAddr}</p> 
<% String ipAddress = request.getHeader("X-FORWARDED-FOR");
String is="";
if (ipAddress == null) {
    is = request.getRemoteAddr();
}
String OS="";
String userAgent = request.getHeader("User-Agent");
if((userAgent.toLowerCase().indexOf("windows") >= 0)){
    OS="windows";
}
else if((userAgent.toLowerCase().indexOf("linux") >= 0)){
    OS="linux";
}

%>

<p>address:<%=is%>  <%=userAgent%></p>
<input type="text" value="<%=is%>" name="ip">
<input type="text" value="<%=OS%>" name="os">
</form>

</body>
</html>

```

findMac.java

```
package checkingfiles;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class mc
 */
@WebServlet("/mc")
public class mc extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#HttpServlet()
     */
    public mc() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        PrintWriter out=response.getWriter();

        Pattern macpt = null;
        String c="";

         String ip=request.getParameter("ip");
         String OS=request.getParameter("os");
            System.out.println(ip);

            System.out.println(OS);
            String[] cmd={};
            if (OS.contains("win")) {
                // Windows
                macpt = Pattern
                        .compile("[0-9a-f]+-[0-9a-f]+-[0-9a-f]+-[0-9a-f]+-[0-9a-f]+-[0-9a-f]+");
                String[] a = { "arp", "-a", ip };

                cmd = a;
            } else {
                // Mac OS X, Linux

                macpt = Pattern.compile("[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+");

              //String ping="ping"+ip;
                String ping="ping 192.168.1.136";

              try {

                  Process p = Runtime.getRuntime().exec(ping);
                  BufferedReader inputStream = new BufferedReader(new InputStreamReader(p.getInputStream()));
                  String s = "";
                  inputStream.close();
                  p.destroy();

                  } catch (Exception e) {
                  e.printStackTrace();
                  }

                 c="ifconfig -a";
               System.out.println(ip);
            }

            try {
                // Run command
                Process p=null;
                if(OS.contains("win")){
                 p = Runtime.getRuntime().exec(cmd);
                }
                else{
                    p = Runtime.getRuntime().exec(c);
                }
                p.waitFor();

                // read output with BufferedReader
                BufferedReader reader = new BufferedReader(new InputStreamReader(
                        p.getInputStream()));
                String line = reader.readLine();
                System.out.println("command"+line);
                // Loop trough lines
                while (line != null) {
                    Matcher m = macpt.matcher(line);

                    // when Matcher finds a Line then return it as result
                    if (m.find()) {
                        System.out.println("Found");
                        System.out.println("MAC: " + m.group(0));
                       // return m.group(0);
                    }

                    line = reader.readLine();

                }

            } catch (IOException e1) {
                e1.printStackTrace();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

    }

}

```

output
Your IP address is: 127.0.0.1

address for:127.0.0.1 Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:36.0) Gecko/20100101 Firefox/36.0

how can i display linux system ip in jsp page