I had a hard time painting the picture of what a server really is. It’s so simple it’s confusing. A Server, low and behold, is a computer.
Your desktop PC or laptop can function as a server - what does that mean “function as a server”. It means that your computer of choice is connected to a network (for example, the internet) and that a program is run on that computer that listens for incoming connections (like a java application you’ve built). That’s it.
It doesn’t even have to be connected to a network, you can run a server locally and have programs on the same computer talk to each other. ( Which is where 99% of the debugging occurs during development. ).
So what are “webservers”? What does a server that hosts a website look like??
Simple. It’s a computer that listens for incoming data, just like ALL servers. What makes it “different” from other servers is how it interprets the data it is being sent and how it responds. Ie, the protocol. You might have heard of HTTP before. It stands for Hypertext Transfer Protocol.
A Protocol is just a fancy word for a set of agreed upon rules people came up with. These rules are vital, because EVERYTHING you send is in bytes, ie, ones 1 and zeroes 0.
01000000
The above bits can be interpreted in lots of ways. It can represent the character ‘@’ or the number ‘64’ for instance, or perhaps a color. Or perhaps the 2 first bits are supposed to represent the x coordinate, the following 2 bits the y coordinate, and the last 4 bits the player score. If we don’t know WHAT the bytes are SUPPOSED to represent (What is agreed before-hand), we have NO chance of making sense of it.
What happens when you open up your music player and you try to play an image file? Most likely the music player would complain that it can’t make sense of the bytes, or that it needs a codec ( Ie, a set of rules of how bytes are supposed to be read in order to convert it into music ). This is why files are littered with “suffixes” like .mp3 or .gif etc. They’re CLUES for the operating system to know which program should be opened to interpret the data. Suffixes have nothing to do with the contents itself. The content in reality is just a bunch of 1’s and 0’s, no matter if it’s music, images, text, movies, whatever.
Try opening a music/image file with notepad (or text editor of choice). That’s what you get when you misinterpret bytes.
This is why protocols and a set of agreed upon rules are absolute key in anything computer related. No matter if it’s over a network or not.
Now you might think you could host your java servers on a simple webserver or website, but that’s probably not the case. Since web hosts come in many different shapes. Some hosts give you access to your very own computer to use ( expensive ), some a virtual machine ( cheaper ) and some gives you only access to common website tasks (limited, cheap) where you can host a website but you can’t actually run any of your own programs/servers (most free/paid website/blog hosting).
My 2 cents.