Where will you be having the lay over? If you need to leave the airport, all you'll need to check is whether or not you need a pre-arranged visa for that country.
We only once had this situation and that was at Singapore airport. Couldn't have been easier as they have hotel rooms you can book in 6 hr blocks. No passport checks or anything...just off the plane, into the hotel room, sleep, back to the next plane. :)
It certainly is possible, and hence the majority of airports have hotels 'attached' (i.e. you can get to them from within the airport, just like in DXB). Obviously, the other alternative, time of day and transit time permitting, is to pop out and explore the city you are transitting through, however quickly!