We review our previous work on the dynamics of one- and two-dimensional arrays of underdamped Josephson junctions placed in a single-mode resonant cavity. Starting from a well-defined model hamiltonian, which includes the effects of driving current and dissipative coupling to a heat bath, we write down the Heisenberg equations of motion for the variables of the Josephson junction and the cavity mode. In the limit of many photons, these equations reduce to coupled ordinary differential equations, which can be solved numerically. We present a review of some characteristic numerical results, which show many features similar to experiment. These include self-induced resonant steps (SIRS's) at voltages V = n hbar Omega/(2e) where Omega is the cavity frequency and n is generally an integer; a threshold number Nc of active rows of junctions above which the array is coherent; and a time-averaged cavity energy which is quadratic in the number of active junctions, when the array is above threshold. When the array is biased on a SIRS, then, for given junction parameters, the power radiated into the cavity varies as the square of the number of active junctions, consistent with expectations for coherent radiation. for a given step, a two-dimensional array radiates much more energy into the cavity than does a one-dimensional array. finally, in two dimensions, we find a strong polarization effect: if the cavity mode is polarized perpendicular to the direction of current injection in a square array, then it does not couple to the array and no power is radiated into the cavity. In the presence of an applied magnetic field, however, a mode with this polarization would couple to the applied current. We speculate that this effect might thus produce SIRS's which would be absent with no applied magnetic field.