Find the indefinite integral $\frac{x\sin x}{1+\cos^2 x}$ 
Evaluate $$\int\frac{x\sin x}{1+\cos^2 x}dx$$

My attempt:
$$I=\int\frac{x\sin x}{1+\cos^2 x}dx=\int x\frac{\sin x}{1+\cos^2 x}dx=\\x\int \frac{\sin x}{1+\cos^2 x}dx-\int \left[\frac{d}{dx}x\int\frac{\sin x}{1+\cos^2 x}dx\right]dx$$

$I'=\displaystyle \int \frac{\sin x}{1+\cos^2 x}dx$
Let $u=\cos x$
$\therefore \dfrac{du}{dx}=-\sin x$
$\implies du=(-\sin x)dx$
$\therefore \displaystyle I'=-\int \frac{du}{1+u^2} $
$\implies I'=-\dfrac{1}{1}\tan^{-1}\left(\dfrac{u}{1}\right)+C \implies I'=-\tan^{-1}(u)+C$
$\implies I'=-\tan^{-1}(\cos x)+C$
$\therefore \displaystyle \int \frac{\sin x}{1+\cos^2 x}dx=-\tan^{-1} (\cos x)+C$

$\therefore \displaystyle I=x\cdot[-\tan^{-1} (\cos x)]-\int [-\tan^{-1} (\cos x)] dx$
$\implies  \displaystyle I=-x \tan^{-1} (\cos x)+\int \tan^{-1} (\cos x)dx$
I cannot understand how to proceed further. Please help.

I doubt you will be able to evaluate the integral without limits, since this link shows that the integral is very complicated, and has polylogarithms. 
With the limits given and using your progress so far, $$\begin{align}\int_0^\pi\frac{x\sin x}{1+\cos^2 x}\,dx&=\left[-x\tan^{-1}(\cos x)\right]_0^\pi+\int_0^\pi\tan^{-1}(\cos x)\,dx\\&=\frac{\pi^2}4-\int_{-\pi/2}^{\pi/2}\tan^{-1}(\sin x)\,dx\end{align}$$The second term is an integral of an odd function on a symmetric interval about $0$. So it is zero. Therefore the answer is $\frac{\pi^2}4$.
