If a person experiences a bad dream that disturbs him and causes him anxiety, that morning he should conduct a ritual called "Hatavat Chalom" which has the power to transform the dream from an ominous sign of future events into a favorable one. This ritual entails assembling three friends and reciting certain texts and verses, as recorded by the Kaf Ha'chayim Sofer in Siman 220, seif kattan 12. One should endeavor to conduct this ritual immediately on the day when he awakens from his dream, and, according to the Kaf Ha'chayim, one should do so even on Shabbat (seif kattan 8) After the Hatavat Chalom, the individual should give some money to charity, so as to eliminate entirely any potentially harmful effects of the frightening dream (seif kattan 14).
A person who is requested to participate in a Hatavat Chalom should not refuse, as it is considered a great Mitzva to help calm one's fellow's fears through this process (seif kattan 4.)
The Kaf Ha'chayim writes that in the opposite case, where a person experiences a pleasant dream, he should make an effort to remember it and even record it in writing (seif kattan 6.)