Evaluation of the upper limit to rare processes in the presence of background, and comparison between the Bayesian and classical approaches