Hmmm...for some odd reason I though you integrated first with "u" before you substitute "u" back into the problem, is this not always the case?
Ohh...I see I just substituted for cos(x) not 1+cos^2(x). I think that I made this a bit more difficult than it had to be.
looking at the problem again, i saw that you just substituted cosx, but as you see, you can make life a lot simpler than that
I = 2* integral u/(1+u^2) du
the observation that 2u = d/du[1+u^2] should imeadiatly tell you that:
I = ln(1+u^2) + c.
The general idea is that:
integral [df/dx]/f(x) dx = ln(f(x) + c