# Problem with value of integral

I calculate $$\int \frac{dx}{\sin^2x+1}=\frac{1}{\sqrt{2}}\arctan(\sqrt{2}\tan x)+c.$$ And then I want to calculate $$\int_{0}^{\pi} \frac{dx}{\sin^2x+1}$$. But $$\tan\pi=\tan0=0$$. So it seems that $$\int_{0}^{\pi} \frac{dx}{\sin^2x+1}=0$$, but it's not true. Where is mistake in my justification ?

Hint: $$\int_0^\pi \frac{dx}{1+\sin(x)^2}=2\int_0^{\pi/2}\frac{dx}{1+\sin(x)^2}$$ And $$\arctan \infty=\pi/2$$. Can you take it from here?
I made the same mistake before. Refer to [Integral][Please identify problem] $\displaystyle\int \cfrac{1}{1+x^4}\>\mathrm{d} x$
The reason of the problem is that $$\arctan(\sqrt{2}\tan x)$$ has a jump but the integral should be continuous, so in the two branches of the function (splitted by the jump point), you need to pick 2 different constants to make it continuous. It also apply to similar situations.