Clearly, the Mellin transform identity for $\cos$ is valid only when $0<\Re s<1$. Hence, we are forced to choose $c\in (0,1)$ for Mellin inverse.
Let’s first solve for $u(x)$ when $0<x<1$.
In this case, the integrand decays exponentially on the left half plane due to $x^s=e^{(\ln x)s}$. Hence, we choose a contour from $c-i\infty$ to $c+i\infty$, and close the contour by attaching a infinitely big semicircle on its left.
Obviously, the integral over the arc vanishes. Therefore, by residue theorem, the Mellin inverse equals
$$\sum\text{residues of $x^{-s}\csc\frac{\pi s}2$ on the left half plane}$$
Note that singularities enclosed are simple poles and are at $s=-2n$, $n=0,1,2,\cdots$. The residue is
$$x^{2n}\lim_{s\to -2n}(s+2n)\csc\frac{\pi s}2=\frac{2}{\pi}(-1)^n x^{2n}$$
Summing the residue from $n=0$ to $\infty$, we found that the Mellin inverse is
$$u(x)=\frac{2}{\pi}\frac{1}{x^2+1}$$
It is (un)surprising that we get the same result for $x>1$ (semicircle on the right half plane) - this is an instance of analytic continuation. Hence, we conclude that $\frac{2}{\pi}\frac{1}{x^2+1} $ is the solution of $u(x)$ for all $x>0$.
Note that this question is highly similar to another one I recently answered. The two different solutions are respectively the real and imaginary parts of $\frac 2\pi \frac1{1-ix}$, depending on whether it is a $\cos$ or a $\sin$.
Best Answer
Here we give a simple example of the use of the Mellin transform to solve a differential equation.
Consider the differential equation $$\begin{equation*} f'(t) + f(t) = 0.\tag{1} \end{equation*}$$ On taking the Mellin transform we find that the corresponding complex difference equation is $-(s-1)\phi(s-1) + \phi(s) = 0$, or $$\phi(s+1) = s \phi(s).$$ This is the recurrence relation for the gamma function, so $$\phi(s) = \Gamma(s)$$ up to an overall numerical factor.
The solution to (1) must be $$\begin{equation*} f(t) = \frac{1}{2\pi i} \int_{c-i\infty}^{c+i\infty} ds\, t^{-s} \Gamma(s),\tag{2} \end{equation*}$$ where $c$ picks out some suitable contour avoiding the poles of $\Gamma$. Recall that $\Gamma$ is meromorphic with simple poles at $0, -1, -2, \ldots$. Existence of the inverse transform (2) can be shown by appealing to the asymptotic behavior of $\Gamma$, $$|\Gamma(x+i y)| \sim \sqrt{2\pi} |y|^{x-1/2} e^{-|y|\pi/2},$$ in the limit $|y|\to \infty$.
We choose $c>0$. With this choice of contour the integral (2) is the Cahen-Mellin integral. Pushing the contour to the left, we pick up all the poles of the gamma function. To calculate the residue, recall that near $s=-n$ $$\Gamma(s) = \frac{(-1)^n}{n!}\frac{1}{s+n} + O(1).$$ This is a straightforward consequence of the recurrence relation for $\Gamma$. Thus, $$\begin{eqnarray*} f(t) &=& \sum_{n=0}^\infty \mathrm{Res}_{s=-n} t^{-s} \Gamma(s) \\ &=& \sum_{n=0}^\infty t^{n}\frac{(-1)^n}{n!} \\ &=& e^{-t}. \end{eqnarray*}$$