Two different methods are proposed for the generation of wide classes of exact solutions to the stationary Gross-Pitaevskii equation (GPE). The first method, suggested by the work of Kondrat'ev and Miller [Izv. Vyssh. Uchebn. Zaved., RadiofizIX, 910 (1966)], applies to one-dimensional (1D) GPE. It is based on the similarity between the GPE and the integrable Gardner equation, all solutions of the latter equation (both stationary and nonstationary ones) generating exact solutions to the GPE. The second method is based on the "inverse problem" for the GPE, i.e., construction of a potential function which provides a desirable solution to the equation. Systematic results are presented for one- and two-dimensional cases. Both methods are illustrated by a variety of localized solutions, including solitary vortices, for both attractive and repulsive nonlinearity in the GPE. The stability of the 1D solutions is tested by direct simulations of the time-dependent GPE.