well looking at the solution the substitution will get us the form

$I(x)= \dfrac{\dfrac{d}{dx} \tan\left(\dfrac x 2\right)}{\tan\left(\dfrac x 2\right)}$ for the integrand

$I(x) = \dfrac{\frac{1}{2} \sec ^2\left(\dfrac{x}{2}\right)}{\tan\left(\dfrac x 2\right)} =$

$\dfrac{1}{2\cos^2\left(\dfrac x 2\right)\tan\left(\dfrac x 2\right)}=$

$\dfrac{1}{2\sin\left(\dfrac x 2\right)\cos\left(\dfrac x 2\right)} = $

$\dfrac{1}{\sin(x)}$

which is the original integrand. So the substitution is correct.