The code in *** daoimpl. Java is as follows:
Public String getcompuname () {Map <string, string> map = system. getenv (); string computername = map. get ("computername"); // get the computer name return computername;} Public String getip () {inetaddress ADDR = NULL; try {ADDR = inetaddress. getlocalhost ();} catch (unknownhostexception e) {e. printstacktrace ();} string IP = ADDR. gethostaddress (). tostring (); // obtain the IP return IP address of the local machine ;}
Need to introduce
import java.util.Map;import java.net.InetAddress;import java.net.UnknownHostException;
Flex front-end code
<? XML version = "1.0" encoding = "UTF-8"?> <S: Application xmlns: FX = "http://ns.adobe.com/mxml/2009" xmlns: S = "Library: // ns.adobe.com/flex/spark" xmlns: MX = "Library: // ns.adobe.com/flex/mx" xmlns: supportclasses = "com. ESRI. AGS. skins. supportclasses. * "minwidth =" 955 "minheight =" 600 "creationcomplete =" Init () "> <FX: SCRIPT> <! [CDATA [import MX. controls. alert; import MX. RPC. events. faultevent; import MX. RPC. events. resultevent; Public Function Init (): void {ipandpcname. getcompuname (); ipandpcname. getip ();} public function ipandpcname_faulthandler (Event: faultevent): void {alert. show (event. tostring ();} public function getcompuname_handler (Event: resultevent): void {alert. show (event. result. tostring ();} public function getip_handler (event: Resultevent): void {alert. show (event. result. tostring () ;}]]> </FX: SCRIPT> <s: layout> <suppclasclasses: attachmentlayout/> </S: layout> <FX: declarations> <! -- Place non-visual elements (such as service and value objects) Here --> <mx: remoteobject id = "ipandpcname" Destination = "systemconfaction" fault = "ipandpcname_faulthandler (Event) "> <mx: method name =" getcompuname "result =" getcompuname_handler (event) "/> <mx: method name =" getip "result =" getip_handler (Event) "/> </MX: remoteobject> </FX: declarations> </S: Application>