This paper presents a geometric approach to the construction of constant weight codes from constant dimension codes. Two classes of constant weight codes are constructed based on the incidence structures in projective and Euclidean geometries, respectively. It is shown that some known optimal codes can be re-obtained in this way. As an application, the constructed codes are used in store-and-forward networks for packet loss recovery. Their decoding is translated into that of the corresponding constant dimension codes. The decoding capability is beyond that of the bounded-distance decoding. Remarkably, for constant weight codes from Koetter-Kschischang codes, the minimum-distance decoding is achieved.