Is exponentiation in P?
Your problem is not in P, for two different reasons:


P is a class of decision problems, but your problem is a function problem.  Instead of P, you should consider its functional equivalent FP.
The output could be exponentially large in the input length: encoding $b$ takes about $\log b$ bits, but encoding $a^b$ takes about $b \log a$ bits.


This still leaves open the possibility that the following problem is in P:


  Given natural numbers $a,b$ and an index $i$, determine the $i$th bit of $a^b$.


While I don't know what the answer to this question is, here is a related problem in FP:


  Given natural numbers $a,b,c$, determine $a^b \bmod c$.


This can be shown using the important technique of repeated squaring.