We present an experimental scheme of preparing the tripartite W state via cavity quantum electrodynamics. The discussion of this scheme indicates that it can be realized by current technologies. Also, this scheme can be directly generalized to prepare the general n-qubit W states.