Limit of the composition of two functions with f not necessarily being continuous.

Solution 1:

Always use the standard theorem for limit of composite functions:

Theorem: If $\lim\limits_{x \to a}g(x) = b$ and $g(x) \neq b$ in a certain deleted neighborhood of $a$ and $\lim\limits_{x \to b}f(x) = L$ then $$\lim_{x \to a}f(g(x)) = L$$

The result you have mentioned is false (for example when $g$ is a constant function say $g(x) = k$ and $f$ is not defined at $k$). A more complicated example of the failure of your result is when $g(0) = 0, g(x) = x\sin(1/x), x\neq 0$ and $f(x) = \dfrac{\sin x}{x}$ and $a = 0$.

Note that the above theorem is very powerful and is the basis of all substitutions used in evaluation of limits (for example replacing $x \to a$ with $x = a + h$ and $h \to 0$).

Also see this answer and related discussion.