Hi,
I have the following code in a utility library and can return the right IP address just
fine (e.g. 192.168.10.10), when it is called from an independent Java program, or when it
is called from some program running on Tomcat:
| InetAddress addr;
| try {
| addr = InetAddress.getLocalHost();
| } catch (UnknownHostException e) {
| e.printStackTrace();
| return null;
| }
| byte[] ipAddr = addr.getAddress();
| String ipAddrStr = "";
| for (int idx = 0; idx< ipAddr.length; idx++)
| {
| if (idx > 0) {
| ipAddrStr += ".";
| }
| ipAddrStr += ipAddr[idx]&0xFF;
| }
|
But when the same piece of code is invoked inside JBoss (from a Struts 2 action), this
only returns "127.0.0.1".
Could someone tell what's going on, and how could I get the right IP address?
Thanks
ak
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4054363#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...