We propose a realizable experimental scheme to prepare a superposition of the vacuum and one-photon states using a typical cavity QED-setup. This is different from previous schemes, where the superposition state of the field is generated by resonant atom-field interaction and the cavity is initially empty. Here, we consider only dispersive atom-field interaction and the initial state of the cavity field is coherent. Then, we determine the parameters to prepare the desired state via atomic postselection. We also include the effect of cavity losses and detection imperfections in our analysis, against which this preparation of the optical qubit in a real Fabry-P{e}rot superconducting cavity is robust. Additionally, we show that this scheme can be used for the preparation of other photon number Fock state superpositions. In summary, our task is achieved with a high fidelity and a postselection probability within experimental reach