It's not a secret anymore!
The moose likes Servlets and the fly likes Get the IP dynamically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Get the IP dynamically" Watch "Get the IP dynamically" New topic

Get the IP dynamically

Monarch Bhojani
Ranch Hand

Joined: Feb 27, 2005
Posts: 46
Hello all
I am making a chat application in which i use JSP and Servlet
Now I have provided the normal login page that is in swing that calls the servlet and does the authentication with the server against databse

Now i would only be giving the swing gui to the client in a jar
But the IP that i pass while compiling and making a jar of swing client is static

Now every time the server changes i need to recompile the class file
Taking the case of yahoo that must be having many servers but the client never needs to specify the IP

Is there any way that my client can get the IP without me having to recompile it everytime before giving it to the client

Jeffrey Spaulding
Ranch Hand

Joined: Jan 15, 2004
Posts: 149
Usually no ip address is passed, instead a servername is used, so the
resolution of the address is done by the DNS.

But if you have resources that need to be read dynamically you can use

This technique is usually applied to localize an application for
different languages, but you can use it for each information that
has to be stored outside of the class.
[ April 18, 2005: Message edited by: Jeffrey Spaulding ]
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

If you package and deliver your Swing app as an applet, you will have the getDocumentBase method available to you.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: Get the IP dynamically
It's not a secret anymore!