You should all be familiar with the identity \int^a_0 f(x) dx = \int^a_0 f(a-x) dx.
If you are not, it is equivalent to the substitution u= a-x. Using that:
Let I = \int^{\pi}_0 \frac{x}{1+\cos^2 x} dx.
Using the identity : I = \int^{\pi}_0 \frac{ \pi - x}{1+\cos^2 (\pi-x)} dx
It is well known that cos ( \pi-x) = -\cos x. So after splitting the numerator to get 2 separate integrals, it can be easily seen that I= \int^{\pi}_0 \frac{\pi-x}{1+\cos^2 x} dx, which can be simplified to:
\frac{2I}{\pi} = \int^{\pi}_0 \frac{1}{1+\cos^2 x} dx.
Now we shall create our focus on the remaining integral without the limits:
Let K= \int \frac{1}{1+\cos^2 x} dx.
To find K, let t=\tan (x/2). The details of my working are simple to do on your own (or just trust me, its just simple algebra) or if you are not familiar with the substitution, the following link provides some information on it and you can check my working for yourself: http://www.ucl.ac.uk/Mathematics/geomath/level2/fint/fisub4.html.
Now we find that K = \int \frac{1+t^2}{1+t^4} dt
We now split the denominator into irreducible quadratic factors and apply partial fractions.
Then we have:
K = \frac{1}{2} \int \left(\frac{1}{t^2+\sqrt{2}t+1} - \frac{1}{-t^2+\sqrt{2}t-1}\right) dx
From there you complete the square on the denominators and use the well known integral \int 1/(x^2+a^2) dx = 1/a \cdot \arctan (x/a).
If you want, fill in the gaps of working on your own, otherwise just trust me:
K = \frac{\sqrt{2}}{2} \left( \arctan (\sqrt{2}t+1) + \arctan (1-\sqrt{2}t)\right).
Now that I have the anti derivative, I have to change the bounds of the original integral to suit that now one. I let t= tan(x/2), the bounds being x= pi and x=0.
So new bounds are t= 1 and t=0. Substituting accordingly into the anti derivative:
\frac{\sqrt{2}}{2} \left( \arctan (\sqrt{2}+1) + \arctan (1-\sqrt{2}) - 2\arctan 1\right).
After some simplifications: I= \frac{\sqrt{2}\pi^2}{8}