In this paper we simulated the pulse propagation and the switching effects in nonlinear fiber Bragg gratings using a combination of Fourier series analysis technique and Jacobi iterative method. The effects of nonlinearity and dispersion on the pulse propagation have been studied extensively. An all optical self switch was designed by this simulation. This switch is operated based on the input power.