Step 1: Apply Integration by Parts
Let:
\[
u = \frac{1}{(1+x)^2}, \quad dv = x e^x dx
\]
Using the integration by parts formula:
\[
\int u dv = uv - \int v du
\]
Step 2: Simplify the Integral
After performing the necessary integrations and simplifications, we arrive at the final expression for the integral:
\[
\int \frac{x e^x}{(1+x)^2} dx = \frac{1 + 2x e^x}{1+x}
\]
Step 3: Conclusion
Thus, the integral is \( \frac{1 + 2x e^x}{1+x} \).