Question: In X-2: X-Men United, Xavier is being controlled by Jason's illusions and made to try to kill all the mutants. However, Jason is not affected by Xavier's attack. Being a mutant, shouldn't he have been since Charles carried out a global attack on the mutants? Is it because he was inside Cerebro with Charles? Does this also explain why Charles isn't affected by his own attack?

Answer: 
Cerebro is shielded, or more accurately, Cerebro is a focusing artifact and cannot target inside its self.

If I recall correctly, it is explicitly stated in the movie that, if you are inside the chamber, you are immune to the effects.
Because the girl in the illusion with Charles is Jason. He tells Charles: "Find all the mutants".  

 Charles doesn't need to focus on the little girl (who is actually Jason), as he knows where she is, and he is not going to look for himself either. He just targets everyone else.