How to get the local IP address?
Hi,
I try to obtain the users local IP address similar to:
InetAddress localHost= InetAddress.getLocalHost();
String localIP = localHost.getHostAddress();
InetAddress[] inetAddress = InetAddress.getAllByName(localHost.getHostName());
for (int k = 0; k < inetAddress.length; k++)
if(!inetAddress [k].getHostAddress().equals(localIP))
return inetAddress [k].getHostAddress();
}This code works fine in a stand alone application. When I try to use it in conjunction with Web Start it only returns 127.0.0.1.
I think there's no Service from Web Start that gives me the users IP address. Or am I wrong?
Does anyone know a solution for this?
Thanks in advance!
Hello,
I use java.net.InetAddress.getLocalHost().getHostName();
in my javaws and I get the real hostname.
Probably your DNS is not correct,
or other possible problem: sign your jars, so you get full access to the System resources.
regards.
Similar Messages
-
How to get the local lan connecting all the system names ?
how to get the local lan connecting all the system names using java?
any body know then send the coding or solutionThis question is asked and answered repeatedly. Search the forum.
-
WebGUI: How to get the users IP-address
Hello.
I have to develop a simple web-application, that will enable users to reset their forgotten passwords or to unlock themselves, if they are locked because of too many failed login-attempts.
As you can imagine, this application must not require a login. For security reasons any action has to be logged.
The username can not be used for logging-purposes, as the application is executed using a default-user defined in transaction SICF. That's why the IP-address of the user's pc has to be written into the log-table.
My problem is, that i do not know how to get it. I have read many articles on help.sap.com, searched in the sap notes, used Google and tried to find usefull functions in our SAP-system, but after two days it still does not work and i do'nt know, what else to try.
At the moment i am able to read the name of the client-pc with my test-coding.
DATA: lv_webgui TYPE xfeld.
STATICS: lv_computer_name TYPE string,
lv_username TYPE string.
CLASS: cl_gui_frontend_services DEFINITION LOAD.
lv_webgui = cl_gui_frontend_services=>www_active.
IF lv_webgui EQ gc_true.
" Begin of experimental coding #1
CALL METHOD cl_gui_frontend_services=>get_computer_name
CHANGING
computer_name = lv_computer_name.
" End of experimental coding #1
" Begin of experimental coding #2
CALL FUNCTION 'ITS_ENV_GET_VARIABLE'
EXPORTING
variable = 'COMPUTERNAME'
CHANGING
value = lv_computer_name.
" End of experimental coding #2
MESSAGE s000(38) WITH lv_computer_name.
ENDIF.
The problem is, that the Internet Explorer 7 (version: 7.0.5730.13CO) shows a warning before the scripts, generated by the ITS, are executed on the client. If the user clicks "abort", the scripts are not executed and the name of the client-pc will not be returned to the server (experimental coding #1 returns the value 'localhost', experimental coding #2 returns an empty string).
That's why the experimental coding is quite useless, because the user is able to avoid it's execution.
In theory i could use experimental coding #2 and stop the execution of the program if an empty string is returned but some users in our company have administrator-privileges and so they can change environment-variables at will. So i am afraid, that this procedure is not an option.
I am quite sure, that there must be a way to read the IP-address directly from the ITS without using the functions in my experimental coding, but i have no clue how this could be done.
Any suggestions would be highly appreciated.
As i do'nt know how to determine the version of our ITS, i have to leave this information out for the moment. If anyone needs this information it would be very kind, if he or she could tell me how to get the required information.
EDIT: As we are using SAP ECC 6.0 and Services are maintained via transaction SICF, it should be ITS 6.40.
Regards
Jörg Neumann
Edited by: Jörg Neumann on Oct 16, 2009 1:27 PMHello Wolfgang.
Thanks for your reply.
I can imagine, that the application as described above seems to be very insecure, but the description is not complete - i left some parts out, as they were not relevant for my problem.
1.) The application can only be reached from our intranet.
2.) Unlocking / Resetting password can be done three times per day, which limits the number of attemps for cracking a password to a total of 20 per day.
3.) The owner of the account will receive an email if the acount was changed by the application. So if somebody tries to crack the password, the owner of the account will get a total
20 3 mails per day - which should make him/her at least a litte suspicious.
I know, that the logged data is quite worthless, as computername and username are read using clientside-scripting and there could be a proxy between the client and the server, but this is exaclty, what i have to develop.
I will keep the logging-problem in mind and talk about it in the next meeting, though i am quite sure, that it wo'nt change anything.
Regards Jörg Neumann
Edited by: Jörg Neumann on Oct 19, 2009 4:57 PM -
How to get the local file system path of an image that loaded into the image component in cq5?
Hi,
I'm having hard time uploading image from filesystem where as drag and drop works.
I'm not getting a path of image selected from filesystem.
here is my code..
private String populateImage() throws Exception {
if (currentNode != null && currentNode.isNode()) {
Node ImageNode = JcrResourceUtil.createPath(currentNode, "image",
null, "nt:unstructured", true);
imageUrl = ImageNode.hasProperty("fileReference") ? ImageNode.getProperty("fileReference").getValue().getString() : "";
imageUrl = imageUrl.trim();
log.info("MANAGE PROFILE BEAN IMAGE URL INSIDE IF IS: " + imageUrl);
} else {
imageUrl = properties.get("fileReference", "");
imageUrl = imageUrl.trim();
log.info("MANAGE PROFILE BEAN IMAGE URL INSIDE ELSE IS: " + imageUrl);
return imageUrl;
So if I drag and drop..
ImageNode.hasProperty("fileReference") is returning a valid path
but if I upload an image it is returning Null.
So how to get the path? any suggestions around would be appreciated...When you say path you mean you want the path to print out in your HTML? Is that accurate? If so you generally need to constructe that path based on the path to the current component. So if you component is located at /content/mysite/en/about/mypage/jcr:content/parsys/image then the path to the image would generally be something like /content/mysite/en/about/mypage/jcr:content/parsys/image.img.jpg/1283829292873.jpg. The .img. selector triggers the servlet associated with the foundation parbase - /libs/foundation/components/parbase/img.GET.java. The reason you reference it this way is that there is no filesystem path to the image - it is stored in the repository not on the file system, and it requires a servlet or script to ge the binary from the repository and steam it.
Normally the way you'd construct this is to use the out of the box Image class - so look at /libs/foundation/components/image/image.jsp. Now this example assumes that your component where you loaded the image extends /libs/foundation/components/parbase. If it doesn't then you either have to change your sling:superResourceType to /libs/foundation/components/parbase or some other component that does exten /libs/foundation/components/parbase. -
How to get the vm ip address in scvmm 2012
Hi,
I want to get the vm ip address in scvmm 2012, who can help me?I have seen lots of people ask this because they can see IP addresses in other Virtualization Consoles, Unfortunately SCVMM doesn't show IP address of the VMs on the console but you can use below script to populate Custom1 property of VMs with IP address
and make Custom1 Column visible (manually) in SCVMM Console... HTH
param ( $VMMServer = 'localhost')
$CustomProp = Get-SCCustomProperty -Name Custom1
$VMs = get-SCVirtualMachine -VMMServer $VMMServer
foreach ($VM in $VMs)
$NetAdp = get-SCVirtualNetworkAdapter -VM $VM.name
if ($NetAdp.IPv4Addresses)
[String[]]$str = $NetAdp.IPv4Addresses
Set-SCCustomPropertyValue -CustomProperty $CustomProp -InputObject $VM -Value "$str"
Disclaimer: The sample script is provided AS IS without warranty of any kind. -
How to get the Clinet IP address in PAR files
Hi Frndzz...
My requirement is to get the log on details of portal users, here i need the User ID n client IP address .
Am trying to get these details from masthead iview PAR file, and this details am passing to a java(custom) class which can create a log_Test.txt file with these details.
User ID am gettiing using UME API like this in masthead PAR file
public void GetWelcomeID(IPortalComponentRequest request, String welcomeClause)
IUserContext userContext = request.getUser();
String usr =userContext.getLogonUid();
But am unable to get the Client IP
In normal JSP will get the client IP like this request.getRemoteAddress()
So in par file i used the IPORTALCOMPONET request to get the client IP, i thought IPORTALCOMPONET request is equalent to HTTPSERVLETRequest request interface.
Any one suggest me that how we can get the Client IP in PAR files .
Thanks in Advance
Regards
RajeshHi,
This is a very interesting question, i searched many time before to get an answer for this on sdn. I havn't found solution. As i know, It is very diffcult to find the ip address from request object.
The main reason is, before reaching the servlet class the request is by pass through other node like dispatcher/central node. If you try to fetch request objects ip from server class i think it will only return you the dispatcher server ip only.
There is a solution for this problem.. if you are able to fetch the ip using some client side scripting and pass it to the servelet as parameter, i hopes you can acheive this.
I will try this and let u know the result.
Others please share your thoughts on this topic.
Regards
Baby -
Dear All
How can I read out the own IP-Address from my MIDP1.0 after I have opened a TCP socket.
I haven't found any method/way in J2ME so far to get the own address that the GSM-provider has assigned to my mobile.
Any hints or ideas would be appreciated
Regards
SektionschefHello,
that is not possible because your mobile phone does not have an actual ip address, at least as far as I understand it. The gprs or hsdc gateway does and then it converts all traffic to some low level protocol which it uses to route the right stuff to your phone.
A simple test would safice, write a simple servlet which logs all connections and then connect to it from your phone. Then disconnect your gprs/hsdc connection and connect again. Try to access the servlet and it will show the same IP address, the one of the gateway facilitating the communication.
Hope this helps.
Regs jP -
How to get the international version address in Payment Medium
Hi,
I am trying to output the payment medium for auto-payment, and I need to get the company name information from the vendor master data. As we are in China, we maintained the Chinese name description in the international version, and English name in the normal name field. My question is how i can get the Chinese name when I set up the payment format via DMEE? thx very much~!Kerry, Were you able to find a solution? If so, can you share your knowledge?
-
How to get the locale/region of the device?
I want to retrieve the locale/region being used on the user's mobile device (doing this on iOS at the moment) and seem to be having difficulty figuring this out.
I need to be able to distinguish between en_US, en_UK, en_CA etc.
Capabilities.language & Capabilities.languages just seem to return the language "en" and not the locale/region being used for the device.
I've also tried using
var defaultLocale:LocaleID = new LocaleID(LocalID.DEFAULT);
trace(defaultlLocale.getLanguage + "_" + defaultLocale.getRegion());
But this just results in an output of "i-default_" (invalid language setting and empty region setting).
Any ideas on what API calls I need to be using, or what I'm doing wrong?
Thanks in advanceWell it looks like if you go into the devices Settings->General->International->Language you can set the preferred language to "British English".
This will then cause Capabilities.languages to return "en-GB" for the first element of the array (the prefferred language). Not sure why it doesn't use proper locale/region codes, but that's another discussion.
The remaining issue is that there is no device setting for "Canadian English", so this doesn't completely solve my problem.
iOS devices do also let you set the "Region Format" which does have a "Canada" setting. I'm guessing that I could use this as a work around if we have access to the "Region Format" data through some AIR API. Does anyone know if we have access to the "Region Format" information on iOS devices and how we'd access that information?
Thanks. -
How to get the cFP IP Address?
Hi, I have a VI running standalone at a cFP 2020, and I can access the front panel using webserver. But to access these VI, I need to know the cFP 2020 IP address. This way, I'm leaving a fixed IP Adress. Now I want to put this cFP inside the company net, and, to do this, I'll select the "Obtain IP address from DHCP server" from the IP settings. But, doing it, if I know the cFP controller name, there's a way to discover the IP address?
Try using String to IP followed by IP to String (and select dot notation). I believe the name should be resolved correctly.
Try to take over the world! -
How to get the real IP address
Due to server changes, the method we used to obtain the ip
address of the user (remote_addr) no longer works since it obtains
a specific IP address that is not the user. For our web logs we
were able to make changes to our web server to use this
"headers.x-client-ip" to obtain the correct IP address. Is there
anything in Coldfusion or in the administrator that can do this as
well?Have a look at : GetHttpRequestData
cheers,
fober -
[JFileChooser] How to get the local network servers list?
Hi, i try to use a JFileChooser (and its FIleSystemView) to retreive the list of local network computer.
In the UI, i can see it but i don't manage to get that list outside of the jfilechooser.
When I do : new File(\\\\Server\\Directory).list() I have a good answer.
But hen I do new File(\\\\).list() to have the server list, i have nothing. I don't manage to list the workgroup too.
Thanks a lot.This question is asked and answered repeatedly. Search the forum.
-
Pls help : How to get the client ip address in EJB
Hi experts,
I need to find the ip addr of the client which makes the remote call.
I tried using
java.rmi.server.RemoteServer.getClientHost()
But it throws ServerNotActiveException .
When I tried this in RMI it works fine perfectly.
If i am right EJB is just similar to RME and it should work in it too..
Can you please help me in finding out the ip address of the client which makes the ejb call.
Thanks & Regards,
MukuntHi Mukunt,
There is no portable way to do this in the Remote EJB programming model. The bean class
is written in a way that is agnostic to those kind of plumbing-related details of the caller.
--ken -
How to get the local date time value
Hi,
I am Australian time zone. I have been using the below code to retrieve meeting start date time from my Sharepoint Calendar.
Console.WriteLine((DateTime)oListItem["EndDate"]);
This used to return the correct local date up until today. I simply read this and store in a database. Today when I check I can see that the date returned is different to what I can see in the Sharepoint calendar.
For and example: In Sharepoint calendar I can see the date as "Oct 1 2014 5:30 PM". But my above code now returns "Oct 1 2014 6:30 AM". This looks to me like UTC time.
But up until today my code above returned the correct local date. Is there any reason for this sudden chahge?
When I read the TimeZone in sharepoint (using RegionalSettings.TimeZone method) it return the correct time zone too.
Any help would be appreciated. I am concerned that I have to now go and change all places where I read the date time from sharepoint.
Thanks, Bimal
BimalHi,
According to your post, my understanding is that you had some issue about the calendar time.
As your code worked well before, the issue may be related to the calendar itself or the site.
As the TimeZone is correct, you can recreate a new calendar to check whether it works.
Or create a new site to check whether it works.
I had made a simple demo to retrieve the calendar EndDate time, you can also check with it.
using (SPSite site = new SPSite("http://YourSiteURL "))
using (SPWeb web = site.OpenWeb())
SPList spList = web.Lists.TryGetList("Calendar1");
if (spList != null)
SPQuery qry = new SPQuery();
qry.ViewFields = @"<FieldRef Name='EventDate' /><FieldRef Name='EndDate' />";
SPListItemCollection listItems = spList.GetItems(qry);
foreach (SPListItem item in listItems)
string startTime = item["EventDate"].ToString();
string endTime = item["EndDate"].ToString();
Console.WriteLine("Start Time:"+startTime);
Console.WriteLine("End Time:"+endTime);
Thanks,
Jason
Forum Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected]
Jason Guo
TechNet Community Support -
How to get the group an address belongs to?
Hello,
I have many groups in my Address Book and I'd like to find in
which is defined one of my addresses?
I've tried opening one group after the other, but this is as stupid
as slow. What is the intelligent way to "see" immediatly which
group an address belongs to?
danThank you Jeffrey.
I have a second problem related to this "address" searching.
I was searching for 3 close addresses which are in my
"All Contacts" group:
Company CEO
Company CSO
Company Technical Director
When I select any one of these addresses, they appear within
my "personnal" group when I press Option key.
This is quite normal, since I created them within this group by "copy" and "paste".
Unfortunately, when I open my "personnal" group, I can only see
the first one of these 3 addresses.
Where is this "apparent" error coming from?
dan
Maybe you are looking for
-
Can't get instant client to work on Win XP
This is driving me nuts. I'm trying to get instantclient10_1 (10.1.0.4) to work reliably on Win XP so I can use it in deploying a Python app I'm writing. I have one XP system on which I have the instant client installed and working. By this I mean th
-
Is it possible to have an adress field with a Custom Object?
Hello, I would like to link a service request to an account and an intermediary such as a travel agency. But the original datamodel only allow one account per Service Request. So, I have created a custom object (Intermediary) that should have similar
-
Service Message Broker service will NOT start
I've done quite a bit of searching on this issue and have found a reasonable amount of potential fixes, all of which I tried and none of which have worked. This service simply is stuck in the "Starting" status. The only way to stop it is to kill the
-
my problem is that I am using a template website and when I bring it into edit it gets all scrambled and images, text, etc. are all over the place. My web page is uneditable. Does anyone know how to fix that ???
-
Hello, I am still discovering all those nice features of CVI2013, so here I am with two questions on compilation: 1) On the Build Options / Configuration Options panel, the checkbox 'Show warning flags in Build Output window' does not seem to have an