yes you can... but all of those are already written... so it's easier to pick up the source code from some site... I think the following site link will lead you in the right direction:
There are basically two ways to make a chat. One is to use applets, the other is to use a data base and have a refreshing page that displays data from that data base. Chatrooms can tend to be complicated if you want emoticons, wispering, different fonts, etc, so you might just want to get some prefab codes like sly mentioned.
Bookmarks