Problem solve Get help with specific problems with your technologies, process and projects.

Why is an IP address required in Java Web server?

I am currently learning servlets but unable to understand when we run Java Web server (I have vqserver in my machine) and then access the servlet from the browser. Why do we need to give either the IP address of our machine or say "localhost" or "abc," which is the computer name given by the identification tab in network neighborhood, and what if I had no Internet connection at home?
In order to access a Java servlet from a browser, you must tell the browser on which machine and port the servlet resides. The IP address or host name of the machine is the primary location-identifier used to find any machine located on an intranet or the Internet. An optional port number can be specified. Along with the IP address or host name and the optional port number, you must specify the servlet's context relative to the IP address or host name.

The name "localhost" is typically the default name that is mapped to a Web/HTTP server's IP address when referencing it from the same machine. Other names can be mapped to the machine's IP address, as well. In your case, "localhost" and "abc" have been mapped to your machine's IP address. When the port number is omitted, port 80 is assumed.

Some example URLs for a servlet called "myservlet" on your local machine might be:


Dig Deeper on Topics Archive

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.