How to get client IP address in Applet
Published: January 5, 2010 , Updated: January 4, 2010 , Author: mkyong
You can use the following example to get the client IP address in Applet. The process is not so straightforward, you have to get the current host and port from where Applet is loaded, and convert it to Socket object.
Socket socket = new Socket(getDocumentBase().getHost(), port); ip = socket.getLocalAddress().getHostAddress();
Example to get IP address in Applet
package com.mkyong.applet; import java.applet.*; import java.awt.Graphics; import java.io.IOException; import java.net.Socket; public class AppletExample extends Applet { String ip; public void init() { try{ int port; if(getDocumentBase().getPort()!=-1){ port = getDocumentBase().getPort(); }else{ port = 80; } Socket socket = new Socket(getDocumentBase().getHost(), port); ip = socket.getLocalAddress().getHostAddress(); }catch(IOException io){ System.out.println(io.getMessage()); } } public void paint( Graphics g ) { StringBuffer sb = new StringBuffer() .append(" IP address : ").append(ip); g.drawString(sb.toString(), 0,100); } }
Any Java questions or problems? please post at this JavaNullPointer.com forum, see you there ~
China and Russia put the blame on some screwed up experiments of US for the earthquake that happened in Haiti.
Chinese and Russian Military scientists, these reports say, are concurring with Canadian researcher, and former Asia-Pacific Bureau Chief of Forbes Magazine, Benjamin Fulford, who in a very disturbing video released from his Japanese offices to the American public, details how the United States attacked China by the firing of a 90 Million Volt Shockwave from the Americans High Frequency Active Auroral Research Program (HAARP) facilities in Alaska
If we can recollect a previous news when US blamed Russia for the earthquake in Georgio. What do you guys think? Is it really possible to create an earthquake by humans?
I came across this article about Haiti Earthquake in some blog it seems very interesting, but conspiracy theories have always been there.